2022-11-07 21:02:56 +09:00
'use strict' ;
require ( '../common' ) ;
const fixtures = require ( '../common/fixtures' ) ;
const assert = require ( 'assert' ) ;
const { spawnSync } = require ( 'child_process' ) ;
{
const child = spawnSync ( process . execPath , [
'--test' ,
fixtures . path ( 'test-runner' , 'extraneous_set_immediate_async.mjs' ) ,
] ) ;
const stdout = child . stdout . toString ( ) ;
2024-08-26 20:54:22 -04:00
assert . match ( stdout , /Error: Test "extraneous async activity test" at .+extraneous_set_immediate_async\.mjs:3:1 generated asynchronous activity after the test ended/m ) ;
assert . match ( stdout , /pass 1/m ) ;
assert . match ( stdout , /fail 1$/m ) ;
assert . match ( stdout , /cancelled 0$/m ) ;
2022-11-07 21:02:56 +09:00
assert . strictEqual ( child . status , 1 ) ;
assert . strictEqual ( child . signal , null ) ;
}
{
const child = spawnSync ( process . execPath , [
'--test' ,
fixtures . path ( 'test-runner' , 'extraneous_set_timeout_async.mjs' ) ,
] ) ;
const stdout = child . stdout . toString ( ) ;
2024-08-26 20:54:22 -04:00
assert . match ( stdout , /Error: Test "extraneous async activity test" at .+extraneous_set_timeout_async\.mjs:3:1 generated asynchronous activity after the test ended/m ) ;
assert . match ( stdout , /pass 1$/m ) ;
assert . match ( stdout , /fail 1$/m ) ;
assert . match ( stdout , /cancelled 0$/m ) ;
2024-04-15 05:27:17 -05:00
assert . strictEqual ( child . status , 1 ) ;
assert . strictEqual ( child . signal , null ) ;
}
{
const child = spawnSync ( process . execPath , [
'--test' ,
fixtures . path ( 'test-runner' , 'async-error-in-test-hook.mjs' ) ,
] ) ;
const stdout = child . stdout . toString ( ) ;
2024-08-26 20:54:22 -04:00
assert . match ( stdout , /Error: Test hook "before" at .+async-error-in-test-hook\.mjs:3:1 generated asynchronous activity after the test ended/m ) ;
assert . match ( stdout , /Error: Test hook "beforeEach" at .+async-error-in-test-hook\.mjs:9:1 generated asynchronous activity after the test ended/m ) ;
assert . match ( stdout , /Error: Test hook "after" at .+async-error-in-test-hook\.mjs:15:1 generated asynchronous activity after the test ended/m ) ;
assert . match ( stdout , /Error: Test hook "afterEach" at .+async-error-in-test-hook\.mjs:21:1 generated asynchronous activity after the test ended/m ) ;
assert . match ( stdout , /pass 1$/m ) ;
assert . match ( stdout , /fail 1$/m ) ;
assert . match ( stdout , /cancelled 0$/m ) ;
2022-11-07 21:02:56 +09:00
assert . strictEqual ( child . status , 1 ) ;
assert . strictEqual ( child . signal , null ) ;
}
2024-07-13 11:10:59 -04:00
{
const child = spawnSync ( process . execPath , [
'--test' ,
2024-12-19 21:10:26 -05:00
'--test-isolation=none' ,
2024-07-13 11:10:59 -04:00
fixtures . path ( 'test-runner' , 'async-error-in-test-hook.mjs' ) ,
] ) ;
const stdout = child . stdout . toString ( ) ;
2024-08-26 20:54:22 -04:00
assert . match ( stdout , /Error: Test hook "before" at .+async-error-in-test-hook\.mjs:3:1 generated asynchronous activity after the test ended/m ) ;
assert . match ( stdout , /Error: Test hook "beforeEach" at .+async-error-in-test-hook\.mjs:9:1 generated asynchronous activity after the test ended/m ) ;
assert . match ( stdout , /Error: Test hook "after" at .+async-error-in-test-hook\.mjs:15:1 generated asynchronous activity after the test ended/m ) ;
assert . match ( stdout , /Error: Test hook "afterEach" at .+async-error-in-test-hook\.mjs:21:1 generated asynchronous activity after the test ended/m ) ;
assert . match ( stdout , /pass 1$/m ) ;
assert . match ( stdout , /fail 0$/m ) ;
assert . match ( stdout , /cancelled 0$/m ) ;
2024-07-13 11:10:59 -04:00
assert . strictEqual ( child . status , 1 ) ;
assert . strictEqual ( child . signal , null ) ;
}