@@ -108,36 +108,83 @@ describe('cache', () => {
108
108
} )
109
109
110
110
describe ( 'allowJs' , ( ) => {
111
- const fileName = 'test-allowJs.test.js'
111
+ const baseFileName = 'test-allowJs'
112
+ const baseFileExt = 'test.js'
112
113
const source = 'export default 42'
113
- const tsConfig = { allowJs : true , outDir : '$$ts-jest$$' }
114
+ const tsConfig = { allowJs : true }
114
115
115
- beforeAll ( ( ) => {
116
- writeFileSync ( fileName , source , 'utf8' )
117
- } )
116
+ describe ( `with program` , ( ) => {
117
+ it ( 'should compile js file for allowJs true with outDir' , ( ) => {
118
+ const fileName = `${ baseFileName } -program-outDir.${ baseFileExt } `
119
+ writeFileSync ( fileName , source , 'utf8' )
120
+ const compiler = makeCompiler ( {
121
+ tsJestConfig : {
122
+ ...baseTsJestConfig ,
123
+ incremental : false ,
124
+ tsConfig : {
125
+ ...tsConfig ,
126
+ outDir : '$$foo$$' ,
127
+ } ,
128
+ } ,
129
+ } )
118
130
119
- afterAll ( ( ) => {
120
- removeSync ( fileName )
121
- } )
131
+ const compiled = compiler . compile ( source , fileName )
122
132
123
- it ( 'should compile js file for allowJs true with normal program' , ( ) => {
124
- const compiler = makeCompiler ( {
125
- tsJestConfig : { ... baseTsJestConfig , incremental : false , tsConfig } ,
133
+ expect ( new ProcessedSource ( compiled , fileName ) ) . toMatchSnapshot ( )
134
+
135
+ removeSync ( fileName )
126
136
} )
127
137
128
- const compiled = compiler . compile ( source , fileName )
138
+ it ( 'should compile js file for allowJs true without outDir' , ( ) => {
139
+ const fileName = `${ baseFileName } -program-no-outDir.${ baseFileExt } `
140
+ writeFileSync ( fileName , source , 'utf8' )
141
+ const compiler = makeCompiler ( {
142
+ tsJestConfig : { ...baseTsJestConfig , incremental : false , tsConfig } ,
143
+ } )
129
144
130
- expect ( new ProcessedSource ( compiled , fileName ) ) . toMatchSnapshot ( )
145
+ const compiled = compiler . compile ( source , fileName )
146
+
147
+ expect ( new ProcessedSource ( compiled , fileName ) ) . toMatchSnapshot ( )
148
+
149
+ removeSync ( fileName )
150
+ } )
131
151
} )
132
152
133
- it ( 'should compile js file for allowJs true with incremental program' , ( ) => {
134
- const compiler = makeCompiler ( {
135
- tsJestConfig : { ...baseTsJestConfig , incremental : true , tsConfig } ,
153
+ describe ( `with incremental program` , ( ) => {
154
+ it ( 'should compile js file for allowJs true with outDir' , ( ) => {
155
+ const fileName = `${ baseFileName } -incremental-outDir.${ baseFileExt } `
156
+ writeFileSync ( fileName , source , 'utf8' )
157
+ const compiler = makeCompiler ( {
158
+ tsJestConfig : {
159
+ ...baseTsJestConfig ,
160
+ incremental : true ,
161
+ tsConfig : {
162
+ ...tsConfig ,
163
+ outDir : '$$foo$$' ,
164
+ } ,
165
+ } ,
166
+ } )
167
+
168
+ const compiled = compiler . compile ( source , fileName )
169
+
170
+ expect ( new ProcessedSource ( compiled , fileName ) ) . toMatchSnapshot ( )
171
+
172
+ removeSync ( fileName )
136
173
} )
137
174
138
- const compiled = compiler . compile ( source , fileName )
175
+ it ( 'should compile js file for allowJs true without outDir' , ( ) => {
176
+ const fileName = `${ baseFileName } -incremental-no-outDir.${ baseFileExt } `
177
+ writeFileSync ( fileName , source , 'utf8' )
178
+ const compiler = makeCompiler ( {
179
+ tsJestConfig : { ...baseTsJestConfig , incremental : true , tsConfig } ,
180
+ } )
139
181
140
- expect ( new ProcessedSource ( compiled , fileName ) ) . toMatchSnapshot ( )
182
+ const compiled = compiler . compile ( source , fileName )
183
+
184
+ expect ( new ProcessedSource ( compiled , fileName ) ) . toMatchSnapshot ( )
185
+
186
+ removeSync ( fileName )
187
+ } )
141
188
} )
142
189
} )
143
190
0 commit comments