-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
150 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
test/parallel/test-runner-no-isolation-different-cwd-watch.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { allowGlobals, mustCall, mustNotCall } from '../common/index.mjs'; | ||
import * as fixtures from '../common/fixtures.mjs'; | ||
import { deepStrictEqual } from 'node:assert'; | ||
import { run } from 'node:test'; | ||
|
||
try { | ||
const controller = new AbortController(); | ||
const stream = run({ | ||
cwd: fixtures.path('test-runner', 'no-isolation'), | ||
isolation: 'none', | ||
watch: true, | ||
signal: controller.signal, | ||
}); | ||
|
||
stream.on('test:fail', () => mustNotCall()); | ||
stream.on('test:pass', mustCall(5)); | ||
stream.on('data', function({ type }) { | ||
if (type === 'test:watch:drained') { | ||
controller.abort(); | ||
} | ||
}); | ||
// eslint-disable-next-line no-unused-vars | ||
for await (const _ of stream); | ||
allowGlobals(globalThis.GLOBAL_ORDER); | ||
deepStrictEqual(globalThis.GLOBAL_ORDER, [ | ||
'before one: <root>', | ||
'suite one', | ||
'before two: <root>', | ||
'suite two', | ||
|
||
'beforeEach one: suite one - test', | ||
'beforeEach two: suite one - test', | ||
'suite one - test', | ||
'afterEach one: suite one - test', | ||
'afterEach two: suite one - test', | ||
|
||
'beforeEach one: test one', | ||
'beforeEach two: test one', | ||
'test one', | ||
'afterEach one: test one', | ||
'afterEach two: test one', | ||
|
||
'before suite two: suite two', | ||
|
||
'beforeEach one: suite two - test', | ||
'beforeEach two: suite two - test', | ||
'suite two - test', | ||
'afterEach one: suite two - test', | ||
'afterEach two: suite two - test', | ||
|
||
'after one: <root>', | ||
'after two: <root>', | ||
]); | ||
} catch (err) { | ||
console.error(err); | ||
process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { allowGlobals, mustCall } from '../common/index.mjs'; | ||
import * as fixtures from '../common/fixtures.mjs'; | ||
import { strictEqual } from 'node:assert'; | ||
import { run } from 'node:test'; | ||
|
||
const stream = run({ | ||
cwd: fixtures.path('test-runner', 'no-isolation'), | ||
isolation: 'none', | ||
}); | ||
|
||
let errors = 0; | ||
stream.on('test:fail', () => { | ||
errors++; | ||
}); | ||
stream.on('test:pass', mustCall(5)); | ||
// eslint-disable-next-line no-unused-vars | ||
for await (const _ of stream); | ||
strictEqual(errors, 0); | ||
allowGlobals(globalThis.GLOBAL_ORDER); | ||
strictEqual(globalThis.GLOBAL_ORDER, [ | ||
'before one: <root>', | ||
'suite one', | ||
'before two: <root>', | ||
'suite two', | ||
|
||
'beforeEach one: suite one - test', | ||
'beforeEach two: suite one - test', | ||
'suite one - test', | ||
'afterEach one: suite one - test', | ||
'afterEach two: suite one - test', | ||
|
||
'beforeEach one: test one', | ||
'beforeEach two: test one', | ||
'test one', | ||
'afterEach one: test one', | ||
'afterEach two: test one', | ||
|
||
'before suite two: suite two', | ||
|
||
'beforeEach one: suite two - test', | ||
'beforeEach two: suite two - test', | ||
'suite two - test', | ||
'afterEach one: suite two - test', | ||
'afterEach two: suite two - test', | ||
|
||
'after one: <root>', | ||
'after two: <root>', | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters