77
88import { wrap } from 'jest-snapshot-serializer-raw' ;
99import { onNodeVersions } from '@jest/test-utils' ;
10- import runJest , { until } from '../runJest' ;
10+ import runJest , { runContinuous } from '../runJest' ;
1111
1212try {
1313 require ( 'async_hooks' ) ;
@@ -27,33 +27,34 @@ function getTextAfterTest(stderr: string) {
2727}
2828
2929it ( 'prints message about flag on slow tests' , async ( ) => {
30- const { stderr} = await until (
31- 'detect-open-handles' ,
32- [ 'outside' ] ,
33- 'Jest did not exit one second after the test run has completed.' ,
30+ const run = runContinuous ( 'detect-open-handles' , [ 'outside' ] ) ;
31+ await run . waitUntil ( ( { stderr} ) =>
32+ stderr . includes (
33+ 'Jest did not exit one second after the test run has completed.' ,
34+ ) ,
3435 ) ;
36+ const { stderr} = await run . end ( ) ;
3537 const textAfterTest = getTextAfterTest ( stderr ) ;
3638
3739 expect ( wrap ( textAfterTest ) ) . toMatchSnapshot ( ) ;
3840} ) ;
3941
4042it ( 'prints message about flag on forceExit' , async ( ) => {
41- const { stderr} = await until (
42- 'detect-open-handles' ,
43- [ 'outside' , '--forceExit' ] ,
44- 'Force exiting Jest' ,
45- ) ;
43+ const run = runContinuous ( 'detect-open-handles' , [ 'outside' , '--forceExit' ] ) ;
44+ await run . waitUntil ( ( { stderr} ) => stderr . includes ( 'Force exiting Jest' ) ) ;
45+ const { stderr} = await run . end ( ) ;
4646 const textAfterTest = getTextAfterTest ( stderr ) ;
4747
4848 expect ( wrap ( textAfterTest ) ) . toMatchSnapshot ( ) ;
4949} ) ;
5050
5151it ( 'prints out info about open handlers' , async ( ) => {
52- const { stderr} = await until (
53- 'detect-open-handles' ,
54- [ 'outside' , '--detectOpenHandles' ] ,
55- 'Jest has detected' ,
56- ) ;
52+ const run = runContinuous ( 'detect-open-handles' , [
53+ 'outside' ,
54+ '--detectOpenHandles' ,
55+ ] ) ;
56+ await run . waitUntil ( ( { stderr} ) => stderr . includes ( 'Jest has detected' ) ) ;
57+ const { stderr} = await run . end ( ) ;
5758 const textAfterTest = getTextAfterTest ( stderr ) ;
5859
5960 expect ( wrap ( textAfterTest ) ) . toMatchSnapshot ( ) ;
@@ -84,11 +85,12 @@ onNodeVersions('>=11', () => {
8485} ) ;
8586
8687it ( 'prints out info about open handlers from inside tests' , async ( ) => {
87- const { stderr} = await until (
88- 'detect-open-handles' ,
89- [ 'inside' , '--detectOpenHandles' ] ,
90- 'Jest has detected' ,
91- ) ;
88+ const run = runContinuous ( 'detect-open-handles' , [
89+ 'inside' ,
90+ '--detectOpenHandles' ,
91+ ] ) ;
92+ await run . waitUntil ( ( { stderr} ) => stderr . includes ( 'Jest has detected' ) ) ;
93+ const { stderr} = await run . end ( ) ;
9294 const textAfterTest = getTextAfterTest ( stderr ) ;
9395
9496 expect ( wrap ( textAfterTest ) ) . toMatchSnapshot ( ) ;
0 commit comments