@@ -2,13 +2,15 @@ jest.mock("fs", () => ({
2
2
readFileSync : jest . fn ( ) ,
3
3
realpathSync : { } ,
4
4
existsSync : jest . fn ( ) ,
5
+ statSync : jest . fn ( ) ,
6
+ stat : jest . fn ( ) ,
5
7
} ) )
6
8
jest . mock ( "path" , ( ) => {
7
9
const path = jest . requireActual ( "path" )
8
10
return { ...path , resolve : jest . fn ( path . resolve ) }
9
11
} )
10
12
11
- import { typescriptify , lookupTSConfig , dirContains } from "../transpiler"
13
+ import { typescriptify , lookupTSConfig , dirContains , babelify } from "../transpiler"
12
14
import * as fs from "fs"
13
15
import * as path from "path"
14
16
@@ -87,3 +89,25 @@ describe("dirContains", () => {
87
89
} )
88
90
}
89
91
} )
92
+
93
+ describe ( "babelify" , ( ) => {
94
+ it ( "does not throw when a filepath is ignored due to babel options, and should return the content unchanged" , ( ) => {
95
+ const dangerfile = `import { a } from 'lodash';
96
+ a();`
97
+
98
+ const existsSyncMock = fs . existsSync as jest . Mock
99
+ const actualFs = jest . requireActual ( "fs" ) as typeof fs
100
+ existsSyncMock . mockImplementation ( ( path ) => path === "/a/b/babel.config.js" || actualFs . existsSync ( path ) )
101
+ jest . mock (
102
+ "/a/b/babel.config.js" ,
103
+ ( ) => {
104
+ return { ignore : [ "/a/b" ] }
105
+ } ,
106
+ { virtual : true }
107
+ )
108
+ const act = ( ) => babelify ( dangerfile , "a/b/" , [ ] )
109
+
110
+ expect ( act ) . not . toThrow ( )
111
+ expect ( act ( ) ) . toEqual ( dangerfile )
112
+ } )
113
+ } )
0 commit comments