/
parse-args.js
40 lines (35 loc) · 1.38 KB
/
parse-args.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* global describe, it */
const {
buildYargs,
hideInstrumenteeArgs,
hideInstrumenterArgs
} = require('../lib/parse-args')
const { join } = require('path')
describe('parse-args', () => {
describe('hideInstrumenteeArgs', () => {
it('hides arguments passed to instrumented app', () => {
process.argv = ['node', 'c8', '--foo=99', 'my-app', '--help']
const instrumenterArgs = hideInstrumenteeArgs()
instrumenterArgs.should.eql(['--foo=99', 'my-app'])
})
})
describe('hideInstrumenterArgs', () => {
it('hides arguments passed to c8 bin', () => {
process.argv = ['node', 'c8', '--foo=99', 'my-app', '--help']
const argv = buildYargs().parse(hideInstrumenteeArgs())
const instrumenteeArgs = hideInstrumenterArgs(argv)
instrumenteeArgs.should.eql(['my-app', '--help'])
argv.tempDirectory.endsWith(join('coverage', 'tmp')).should.be.equal(true)
})
})
describe('with NODE_V8_COVERAGE already set', () => {
it('should not override it', () => {
const NODE_V8_COVERAGE = process.env.NODE_V8_COVERAGE
process.env.NODE_V8_COVERAGE = './coverage/tmp_'
process.argv = ['node', 'c8', '--foo=99', 'my-app', '--help']
const argv = buildYargs().parse(hideInstrumenteeArgs())
argv.tempDirectory.endsWith('/coverage/tmp_').should.be.equal(true)
process.env.NODE_V8_COVERAGE = NODE_V8_COVERAGE
})
})
})