UNPKG

761 BJavaScriptView Raw
1'use strict'
2
3/* demonstrates use in a mocha test script */
4
5const assert = require('assert')
6const commandLineArgs = require('../')
7
8/*
9enable partial parsing to prevent `UNKNOWN_OPTION` exceptions being thrown
10if the user sets mocha-specific options (e.g. --no-colors)
11*/
12const options = commandLineArgs({ name: 'value', type: Number }, { partial: true })
13
14describe('Array', function () {
15 describe('#indexOf()', function () {
16 it('should pass when the supplied value is between 1 and 3', function () {
17 assert.ok([ 1, 2, 3 ].indexOf(options.value) > -1)
18 })
19 })
20})
21
22/*
23Example output:
24
25$ mocha example/mocha.js --value 3 --no-colors
26
27 Array
28 #indexOf()
29 ✓ should pass when the supplied value is between 1 and 3
30
31 1 passing (7ms)
32
33*/