@@ -3,7 +3,6 @@ import * as fs from 'fs';
3
3
import * as os from 'os' ;
4
4
import * as path from 'path' ;
5
5
import type { JSONSchemaForNPMPackageJsonFiles } from '@schemastore/package' ;
6
- import stripAnsi from 'strip-ansi' ;
7
6
import { create } from 'ts-node' ;
8
7
import { detectJestVersion } from '../detectJestVersion' ;
9
8
@@ -21,19 +20,19 @@ const relativePathToFn = 'eslint-plugin-jest/lib/rules/detectJestVersion.js';
21
20
const runNodeScript = ( cwd : string , script : string ) => {
22
21
const { stdout, stderr } = spawnSync (
23
22
'node' ,
24
- [ '-e ' , script . split ( '\n' ) . join ( ' ' ) ] ,
23
+ [ '-p ' , script . split ( '\n' ) . join ( ' ' ) ] ,
25
24
{ cwd, encoding : 'utf-8' } ,
26
25
) ;
27
26
28
- return { stdout : stripAnsi ( stdout . trim ( ) ) , stderr : stripAnsi ( stderr . trim ( ) ) } ;
27
+ return { stdout : stdout . trim ( ) , stderr : stderr . trim ( ) } ;
29
28
} ;
30
29
31
30
const runDetectJestVersion = ( cwd : string ) => {
32
31
return runNodeScript (
33
32
cwd ,
34
33
`
35
34
try {
36
- console.log( require('${ relativePathToFn } ').detectJestVersion() );
35
+ require('${ relativePathToFn } ').detectJestVersion();
37
36
} catch (error) {
38
37
console.error(error.message);
39
38
}
@@ -190,7 +189,7 @@ describe('detectJestVersion', () => {
190
189
191
190
const { stdout, stderr } = runDetectJestVersion ( projectDir ) ;
192
191
193
- expect ( stdout ) . toBe ( '' ) ;
192
+ expect ( stdout ) . toBe ( 'undefined ' ) ;
194
193
expect ( stderr ) . toContain ( 'Unable to detect Jest version' ) ;
195
194
} ) ;
196
195
} ) ;
0 commit comments