| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6ec735c commit cce803b
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -982,6 +982,18 @@ function run(options = kEmptyObject) { | |||
| 982 | 982 | testTagFilters, | |
| 983 | 983 | }; | |
| 984 | 984 | ||
| 985 | + if (isolation === 'none') { | ||
| 986 | + if (testNamePatterns != null) { | ||
| 987 | + globalOptions.testNamePatterns = testNamePatterns; | ||
| 988 | + } | ||
| 989 | + if (testSkipPatterns != null) { | ||
| 990 | + globalOptions.testSkipPatterns = testSkipPatterns; | ||
| 991 | + } | ||
| 992 | + if (only != null) { | ||
| 993 | + globalOptions.only = only; | ||
| 994 | + } | ||
| 995 | + } | ||
| 996 | + | ||
| 985 | 997 | const root = createTestTree(rootTestOptions, globalOptions); | |
| 986 | 998 | let testFiles = files ?? createTestFileList(globPatterns, cwd); | |
| 987 | 999 | const { isTestRunner } = globalOptions; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,32 @@ | |||
| 1 | + import { run } from 'node:test'; | ||
| 2 | + import { tap } from 'node:test/reporters'; | ||
| 3 | + import { parseArgs } from 'node:util'; | ||
| 4 | + | ||
| 5 | + const { | ||
| 6 | + values, | ||
| 7 | + } = parseArgs({ | ||
| 8 | + args: process.argv.slice(2), | ||
| 9 | + options: { | ||
| 10 | + file: { type: 'string' }, | ||
| 11 | + only: { type: 'boolean' }, | ||
| 12 | + 'name-pattern': { type: 'string' }, | ||
| 13 | + 'skip-pattern': { type: 'string' }, | ||
| 14 | + }, | ||
| 15 | + }); | ||
| 16 | + | ||
| 17 | + const opts = { | ||
| 18 | + isolation: 'none', | ||
| 19 | + files: [values.file], | ||
| 20 | + }; | ||
| 21 | + | ||
| 22 | + if (values.only) { | ||
| 23 | + opts.only = true; | ||
| 24 | + } | ||
| 25 | + if (values['name-pattern']) { | ||
| 26 | + opts.testNamePatterns = [new RegExp(values['name-pattern'])]; | ||
| 27 | + } | ||
| 28 | + if (values['skip-pattern']) { | ||
| 29 | + opts.testSkipPatterns = [new RegExp(values['skip-pattern'])]; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + run(opts).compose(tap).pipe(process.stdout); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -870,6 +870,48 @@ describe('forceExit', () => { | |||
| 870 | 870 | }); | |
| 871 | 871 | }); | |
| 872 | 872 | ||
| 873 | + describe('with isolation="none"', () => { | ||
| 874 | + const isolationNoneFixture = fixtures.path('test-runner', 'test-runner-isolation-none.mjs'); | ||
| 875 | + | ||
| 876 | + it('should pass only to children', async () => { | ||
| 877 | + const child = await common.spawnPromisified(process.execPath, [ | ||
| 878 | + isolationNoneFixture, | ||
| 879 | + '--file', join(testFixtures, 'test_only.js'), | ||
| 880 | + '--only', | ||
| 881 | + ]); | ||
| 882 | + | ||
| 883 | + assert.strictEqual(child.stderr, ''); | ||
| 884 | + assert.strictEqual(child.code, 0); | ||
| 885 | + assert.match(child.stdout, /ok 1 - this should be executed/); | ||
| 886 | + assert.match(child.stdout, /# tests 1/); | ||
| 887 | + }); | ||
| 888 | + | ||
| 889 | + it('should skip tests not matching testNamePatterns - RegExp', async () => { | ||
| 890 | + const child = await common.spawnPromisified(process.execPath, [ | ||
| 891 | + isolationNoneFixture, | ||
| 892 | + '--file', join(testFixtures, 'default-behavior/test/skip_by_name.cjs'), | ||
| 893 | + '--name-pattern', 'executed', | ||
| 894 | + ]); | ||
| 895 | + | ||
| 896 | + assert.strictEqual(child.stderr, ''); | ||
| 897 | + assert.strictEqual(child.code, 0); | ||
| 898 | + assert.match(child.stdout, /ok 1 - this should be executed/); | ||
| 899 | + assert.match(child.stdout, /# tests 1/); | ||
| 900 | + }); | ||
| 901 | + | ||
| 902 | + it('should skip tests matching testSkipPatterns - RegExp', async () => { | ||
| 903 | + const child = await common.spawnPromisified(process.execPath, [ | ||
| 904 | + isolationNoneFixture, | ||
| 905 | + '--file', join(testFixtures, 'default-behavior/test/skip_by_name.cjs'), | ||
| 906 | + '--skip-pattern', 'skipped', | ||
| 907 | + ]); | ||
| 908 | + | ||
| 909 | + assert.strictEqual(child.stderr, ''); | ||
| 910 | + assert.strictEqual(child.code, 0); | ||
| 911 | + assert.match(child.stdout, /ok 1 - this should be executed/); | ||
| 912 | + assert.match(child.stdout, /# tests 1/); | ||
| 913 | + }); | ||
| 914 | + }); | ||
| 873 | 915 | ||
| 874 | 916 | // exitHandler doesn't run until after the tests / after hooks finish. | |
| 875 | 917 | process.on('exit', () => { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments