11import { exec } from 'node:child_process'
2+ import { join } from 'node:path'
23
34describe ( 'integration test' , function ( ) {
5+ const isWindows = process . platform === 'win32'
6+
47 test . concurrent . each ( [ 'ts-node' , 'ts-node-dev' ] ) (
58 'integration with %s' ,
69 async function ( instance ) {
710 await new Promise ( function ( resolve ) {
8- const child = exec ( `${ instance } "${ process . cwd ( ) } /test/typescript-jest/integration/instance.ts"` )
11+ const compilerOpts = JSON . stringify ( {
12+ module : 'commonjs' ,
13+ moduleResolution : 'node' ,
14+ esModuleInterop : true
15+ } )
16+
17+ const optionsArg = isWindows
18+ ? `"${ compilerOpts . replace ( / " / g, '\\"' ) } "`
19+ : `'${ compilerOpts } '`
20+
21+ const filePath = join (
22+ process . cwd ( ) ,
23+ 'test' ,
24+ 'typescript-jest' ,
25+ 'integration' ,
26+ 'instance.ts'
27+ )
28+
29+ const child = exec (
30+ `npx ${ instance } --compiler-options ${ optionsArg } "${ filePath } "`
31+ )
32+
933 let stderr = ''
1034 child . stderr ?. on ( 'data' , function ( b ) {
1135 stderr = stderr + b . toString ( )
@@ -14,13 +38,14 @@ describe('integration test', function () {
1438 child . stdout ?. on ( 'data' , function ( b ) {
1539 stdout = stdout + b . toString ( )
1640 } )
41+
1742 child . once ( 'close' , function ( ) {
1843 expect ( stderr . includes ( 'failed' ) ) . toStrictEqual ( false )
1944 expect ( stdout . includes ( 'success' ) ) . toStrictEqual ( true )
2045 resolve ( '' )
2146 } )
2247 } )
2348 } ,
24- 30000
49+ isWindows ? 60000 : 30000
2550 )
2651} )
0 commit comments