1 |
|
2 |
|
3 | /* demonstrates use in a mocha test script */
|
4 |
|
5 | const assert = require('assert')
|
6 | const commandLineArgs = require('../')
|
7 |
|
8 | /*
|
9 | enable partial parsing to prevent `UNKNOWN_OPTION` exceptions being thrown
|
10 | if the user sets mocha-specific options (e.g. --no-colors)
|
11 | */
|
12 | const options = commandLineArgs({ name: 'value', type: Number }, { partial: true })
|
13 |
|
14 | describe('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 | /*
|
23 | Example 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 | */
|