Skip to content

Commit de6a09b

Browse files
committed
test: add flags
1 parent a80f4bb commit de6a09b

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Empty file used by test/parallel/test-runner-flag-propagation.js

test/fixtures/test-runner/flag-propagation/test.mjs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test } from 'node:test';
2-
import { strictEqual } from 'node:assert';
2+
import { deepStrictEqual } from 'node:assert';
33
import internal from 'internal/options';
44
import { parseArgs } from 'node:util';
55

@@ -21,20 +21,26 @@ const options = {
2121

2222
const { values } = parseArgs({ args: process.argv.slice(2), options });
2323

24-
const { flag, expected, description } = values;
24+
let { flag, expected, description } = values;
2525

2626
test(description, () => {
2727
const optionValue = internal.getOptionValue(flag);
28+
const isArrayOption = Array.isArray(optionValue);
29+
30+
if (isArrayOption) {
31+
expected = [expected];
32+
}
33+
2834
console.error(`testing flag: ${flag}, found value: ${optionValue}, expected: ${expected}`);
2935

3036
const isNumber = !isNaN(Number(expected));
3137
const booleanValue = expected === 'true' || expected === 'false';
3238
if (booleanValue) {
33-
strictEqual(optionValue, expected === 'true');
39+
deepStrictEqual(optionValue, expected === 'true');
3440
return;
3541
} else if (isNumber) {
36-
strictEqual(Number(optionValue), Number(expected));
42+
deepStrictEqual(Number(optionValue), Number(expected));
3743
} else{
38-
strictEqual(optionValue, expected);
44+
deepStrictEqual(optionValue, expected);
3945
}
4046
});

test/parallel/test-runner-flag-propagation.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ describe('test runner flag propagation', () => {
2323
['--test-coverage-branches', '100', '100'],
2424
['--test-coverage-functions', '100', '100'],
2525
['--test-coverage-lines', '100', '100'],
26-
// ['--test-coverage-exclude', 'test/**', 'test/**'],
27-
// ['--test-coverage-include', 'src/**', 'src/**'],
26+
['--experimental-test-coverage', '', false],
27+
['--test-coverage-exclude', 'test/**', 'test/**'],
28+
['--test-coverage-include', 'src/**', 'src/**'],
2829
['--test-update-snapshots', '', true],
30+
['--import', './index.js', './index.js'],
31+
['--require', './index.js', './index.js'],
2932
];
3033

3134
// Path to the static fixture

0 commit comments

Comments
 (0)