@@ -40,8 +40,8 @@ test('uses default presets when userOptions is "default"', t => {
40
40
const userOptions = 'default' ;
41
41
const compileEnhancements = true ;
42
42
43
- const projectDir = uniqueTempDir ( ) ;
44
- const cacheDir = path . join ( projectDir , 'cache' ) ;
43
+ const projectDir = fixture ( 'no-babel-config' ) ;
44
+ const cacheDir = path . join ( uniqueTempDir ( ) , 'cache' ) ;
45
45
return babelConfigHelper . build ( projectDir , cacheDir , userOptions , compileEnhancements )
46
46
. then ( result => {
47
47
const options = result . getOptions ( ) ;
@@ -80,8 +80,8 @@ test('uses userOptions for babel options when userOptions is an object', t => {
80
80
} ;
81
81
const compileEnhancements = true ;
82
82
83
- const projectDir = uniqueTempDir ( ) ;
84
- const cacheDir = path . join ( projectDir , 'cache' ) ;
83
+ const projectDir = fixture ( 'no-babel-config' ) ;
84
+ const cacheDir = path . join ( uniqueTempDir ( ) , 'cache' ) ;
85
85
return babelConfigHelper . build ( projectDir , cacheDir , userOptions , compileEnhancements )
86
86
. then ( result => {
87
87
const options = result . getOptions ( ) ;
@@ -130,8 +130,8 @@ test('supports .babelrc.js files', t => {
130
130
} ) ;
131
131
132
132
test ( 'adds babel-plugin-syntax-object-rest-spread for node versions > 8.3.0' , t => {
133
- const projectDir = uniqueTempDir ( ) ;
134
- const cacheDir = path . join ( projectDir , 'cache' ) ;
133
+ const projectDir = fixture ( 'no-babel-config' ) ;
134
+ const cacheDir = path . join ( uniqueTempDir ( ) , 'cache' ) ;
135
135
136
136
return withNodeVersion ( '9.0.0' , ( ) => babelConfigHelper . build ( projectDir , cacheDir , 'default' , true ) )
137
137
. then ( result => {
@@ -141,8 +141,8 @@ test('adds babel-plugin-syntax-object-rest-spread for node versions > 8.3.0', t
141
141
} ) ;
142
142
143
143
test ( 'adds babel-plugin-syntax-object-rest-spread for node versions == 8.3.0' , t => {
144
- const projectDir = uniqueTempDir ( ) ;
145
- const cacheDir = path . join ( projectDir , 'cache' ) ;
144
+ const projectDir = fixture ( 'no-babel-config' ) ;
145
+ const cacheDir = path . join ( uniqueTempDir ( ) , 'cache' ) ;
146
146
147
147
return withNodeVersion ( '8.3.0' , ( ) => babelConfigHelper . build ( projectDir , cacheDir , 'default' , true ) )
148
148
. then ( result => {
@@ -152,8 +152,8 @@ test('adds babel-plugin-syntax-object-rest-spread for node versions == 8.3.0', t
152
152
} ) ;
153
153
154
154
test ( 'does not add babel-plugin-syntax-object-rest-spread for node versions < 8.3.0' , t => {
155
- const projectDir = uniqueTempDir ( ) ;
156
- const cacheDir = path . join ( projectDir , 'cache' ) ;
155
+ const projectDir = fixture ( 'no-babel-config' ) ;
156
+ const cacheDir = path . join ( uniqueTempDir ( ) , 'cache' ) ;
157
157
158
158
return withNodeVersion ( '8.2.0' , ( ) => babelConfigHelper . build ( projectDir , cacheDir , 'default' , true ) )
159
159
. then ( result => {
@@ -166,8 +166,8 @@ test('should not include transform-test-files when compileEnhancements is false'
166
166
const userOptions = 'default' ;
167
167
const compileEnhancements = false ;
168
168
169
- const projectDir = uniqueTempDir ( ) ;
170
- const cacheDir = path . join ( projectDir , 'cache' ) ;
169
+ const projectDir = fixture ( 'no-babel-config' ) ;
170
+ const cacheDir = path . join ( uniqueTempDir ( ) , 'cache' ) ;
171
171
return babelConfigHelper . build ( projectDir , cacheDir , userOptions , compileEnhancements )
172
172
. then ( result => {
173
173
const options = result . getOptions ( ) ;
@@ -178,8 +178,8 @@ test('should not include transform-test-files when compileEnhancements is false'
178
178
} ) ;
179
179
180
180
test ( 'caches and uses results' , t => {
181
- const projectDir = uniqueTempDir ( ) ;
182
- const cacheDir = path . join ( projectDir , 'cache' ) ;
181
+ const projectDir = fixture ( 'no-babel-config' ) ;
182
+ const cacheDir = path . join ( uniqueTempDir ( ) , 'cache' ) ;
183
183
return babelConfigHelper . build ( projectDir , cacheDir , 'default' , true )
184
184
. then ( result => {
185
185
const files = fs . readdirSync ( cacheDir ) ;
@@ -209,8 +209,8 @@ test('caches and uses results', t => {
209
209
} ) ;
210
210
211
211
test ( 'discards cache if userOptions change' , t => {
212
- const projectDir = uniqueTempDir ( ) ;
213
- const cacheDir = path . join ( projectDir , 'cache' ) ;
212
+ const projectDir = fixture ( 'no-babel-config' ) ;
213
+ const cacheDir = path . join ( uniqueTempDir ( ) , 'cache' ) ;
214
214
const userOptions = { } ;
215
215
return babelConfigHelper . build ( projectDir , cacheDir , userOptions , true )
216
216
. then ( result => {
@@ -228,15 +228,16 @@ test('discards cache if userOptions change', t => {
228
228
} ) ;
229
229
230
230
test ( 'updates cached verifier if dependency hashes change' , t => {
231
- const projectDir = uniqueTempDir ( ) ;
232
- const cacheDir = path . join ( projectDir , 'cache' ) ;
233
- const depFile = path . join ( projectDir , 'plugin.js' ) ;
231
+ const projectDir = fixture ( 'no-babel-config' ) ;
232
+ const tempDir = uniqueTempDir ( ) ;
233
+ const cacheDir = path . join ( tempDir , 'cache' ) ;
234
+ const depFile = path . join ( tempDir , 'plugin.js' ) ;
234
235
235
236
makeDir . sync ( cacheDir ) ;
236
237
fs . writeFileSync ( depFile , 'module.exports = () => ({})' ) ;
237
238
238
239
const userOptions = {
239
- plugins : [ './plugin.js' ]
240
+ plugins : [ depFile ]
240
241
} ;
241
242
return babelConfigHelper . build ( projectDir , cacheDir , userOptions , true )
242
243
. then ( result => {
@@ -255,8 +256,8 @@ test('updates cached verifier if dependency hashes change', t => {
255
256
} ) ;
256
257
257
258
test ( 'crashes if cached files cannot be read' , t => {
258
- const projectDir = uniqueTempDir ( ) ;
259
- const cacheDir = path . join ( projectDir , 'cache' ) ;
259
+ const projectDir = fixture ( 'no-babel-config' ) ;
260
+ const cacheDir = path . join ( uniqueTempDir ( ) , 'cache' ) ;
260
261
261
262
t . plan ( 1 ) ;
262
263
return babelConfigHelper . build ( projectDir , cacheDir , 'default' , true )
0 commit comments