11import { dirname , join } from 'node:path' ;
22import { fileURLToPath } from 'node:url' ;
3- import { expect , it } from '@rstest/core' ;
3+ import { it } from '@rstest/core' ;
44import { runRstestCli } from '../../scripts/' ;
55
66const __filename = fileURLToPath ( import . meta. url ) ;
77
88const __dirname = dirname ( __filename ) ;
9- it ( 'should catch `Worker exited unexpectedly ` error correctly' , async ( ) => {
10- const { cli } = await runRstestCli ( {
9+ it ( 'should catch `process.kill ` error correctly' , async ( ) => {
10+ const { cli, expectExecFailed , expectLog } = await runRstestCli ( {
1111 command : 'rstest' ,
1212 args : [ 'run' , 'processKill.test.ts' , '--disableConsoleIntercept' ] ,
1313 options : {
@@ -16,10 +16,12 @@ it('should catch `Worker exited unexpectedly` error correctly', async () => {
1616 } ,
1717 } ,
1818 } ) ;
19- await cli . exec ;
20- expect ( cli . exec . process ?. exitCode ) . toBe ( 1 ) ;
19+ await expectExecFailed ( ) ;
2120
2221 const logs = cli . stdout . split ( '\n' ) . filter ( Boolean ) ;
2322
24- expect ( logs . find ( ( log ) => log . includes ( 'Test Files 1 failed' ) ) ) . toBeDefined ( ) ;
23+ expectLog ( 'Test Files 1 failed' , logs ) ;
24+
25+ expectLog ( 'FAIL processKill.test.ts > process.kill' , logs ) ;
26+ expectLog ( / p r o c e s s .k i l l u n e x p e c t e d l y c a l l e d / , logs ) ;
2527} ) ;
0 commit comments