| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d7266cd commit 4368303
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1854,6 +1854,11 @@ class Suite extends Test { | |||
| 1854 | 1854 | return { __proto__: null, ctx, args: [ctx] }; | |
| 1855 | 1855 | } | |
| 1856 | 1856 | ||
| 1857 | + async filteredRun() { | ||
| 1858 | + await this.buildSuite; | ||
| 1859 | + return super.filteredRun(); | ||
| 1860 | + } | ||
| 1861 | + | ||
| 1857 | 1862 | async run() { | |
| 1858 | 1863 | this.computeInheritedHooks(); | |
| 1859 | 1864 | const hookArgs = this.getRunArgs(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,17 @@ | |||
| 1 | + import test from 'node:test'; | ||
| 2 | + import { setTimeout as delay } from 'node:timers/promises'; | ||
| 3 | + | ||
| 4 | + test.suite('Outer', async () => { | ||
| 5 | + await delay(1); | ||
| 6 | + | ||
| 7 | + // This suite is filtered out by name. Its build is still pending when the | ||
| 8 | + // filtered run starts, so the subtest below is registered late. | ||
| 9 | + test.suite('Nested A', async () => { | ||
| 10 | + await delay(1); | ||
| 11 | + test('Nested A test', async () => {}); | ||
| 12 | + }); | ||
| 13 | + | ||
| 14 | + test.suite('Nested C', async () => { | ||
| 15 | + test('Nested C test', async () => {}); | ||
| 16 | + }); | ||
| 17 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,8 @@ const { test } = require('node:test'); | |||
| 7 | 7 | ||
| 8 | 8 | const fixture1 = fixtures.path('test-runner', 'no-isolation', 'one.test.js'); | |
| 9 | 9 | const fixture2 = fixtures.path('test-runner', 'no-isolation', 'two.test.js'); | |
| 10 | + const asyncBuildFilteredSuite = | ||
| 11 | + fixtures.path('test-runner', 'filtered-suite-async-build.mjs'); | ||
| 10 | 12 | ||
| 11 | 13 | test('works with --test-only', () => { | |
| 12 | 14 | const args = [ | |
@@ -71,6 +73,27 @@ test('works with --test-name-pattern', () => { | |||
| 71 | 73 | assert.match(stdout, /# suites 0/); | |
| 72 | 74 | }); | |
| 73 | 75 | ||
| 76 | + test('filtered suites with an async build do not leave cancelled tests', () => { | ||
| 77 | + const args = [ | ||
| 78 | + '--test', | ||
| 79 | + '--test-reporter=tap', | ||
| 80 | + '--test-isolation=none', | ||
| 81 | + '--test-name-pattern=C', | ||
| 82 | + asyncBuildFilteredSuite, | ||
| 83 | + ]; | ||
| 84 | + const child = spawnSync(process.execPath, args); | ||
| 85 | + const stdout = child.stdout.toString(); | ||
| 86 | + | ||
| 87 | + assert.strictEqual(child.status, 0); | ||
| 88 | + assert.strictEqual(child.signal, null); | ||
| 89 | + assert.match(stdout, /# tests 1/); | ||
| 90 | + assert.match(stdout, /# suites 2/); | ||
| 91 | + assert.match(stdout, /# pass 1/); | ||
| 92 | + assert.match(stdout, /# fail 0/); | ||
| 93 | + assert.match(stdout, /# cancelled 0/); | ||
| 94 | + assert.doesNotMatch(stdout, /parentAlreadyFinished/); | ||
| 95 | + }); | ||
| 96 | + | ||
| 74 | 97 | test('works with --test-skip-pattern', () => { | |
| 75 | 98 | const args = [ | |
| 76 | 99 | '--test', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments