Skip to content

Commit a262f28

Browse files
committed
Keep babel-config tests within AVA source directory
1 parent f6e1301 commit a262f28

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

test/babel-config.js

+23-22
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ test('uses default presets when userOptions is "default"', t => {
4040
const userOptions = 'default';
4141
const compileEnhancements = true;
4242

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');
4545
return babelConfigHelper.build(projectDir, cacheDir, userOptions, compileEnhancements)
4646
.then(result => {
4747
const options = result.getOptions();
@@ -80,8 +80,8 @@ test('uses userOptions for babel options when userOptions is an object', t => {
8080
};
8181
const compileEnhancements = true;
8282

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');
8585
return babelConfigHelper.build(projectDir, cacheDir, userOptions, compileEnhancements)
8686
.then(result => {
8787
const options = result.getOptions();
@@ -130,8 +130,8 @@ test('supports .babelrc.js files', t => {
130130
});
131131

132132
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');
135135

136136
return withNodeVersion('9.0.0', () => babelConfigHelper.build(projectDir, cacheDir, 'default', true))
137137
.then(result => {
@@ -141,8 +141,8 @@ test('adds babel-plugin-syntax-object-rest-spread for node versions > 8.3.0', t
141141
});
142142

143143
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');
146146

147147
return withNodeVersion('8.3.0', () => babelConfigHelper.build(projectDir, cacheDir, 'default', true))
148148
.then(result => {
@@ -152,8 +152,8 @@ test('adds babel-plugin-syntax-object-rest-spread for node versions == 8.3.0', t
152152
});
153153

154154
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');
157157

158158
return withNodeVersion('8.2.0', () => babelConfigHelper.build(projectDir, cacheDir, 'default', true))
159159
.then(result => {
@@ -166,8 +166,8 @@ test('should not include transform-test-files when compileEnhancements is false'
166166
const userOptions = 'default';
167167
const compileEnhancements = false;
168168

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');
171171
return babelConfigHelper.build(projectDir, cacheDir, userOptions, compileEnhancements)
172172
.then(result => {
173173
const options = result.getOptions();
@@ -178,8 +178,8 @@ test('should not include transform-test-files when compileEnhancements is false'
178178
});
179179

180180
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');
183183
return babelConfigHelper.build(projectDir, cacheDir, 'default', true)
184184
.then(result => {
185185
const files = fs.readdirSync(cacheDir);
@@ -209,8 +209,8 @@ test('caches and uses results', t => {
209209
});
210210

211211
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');
214214
const userOptions = {};
215215
return babelConfigHelper.build(projectDir, cacheDir, userOptions, true)
216216
.then(result => {
@@ -228,15 +228,16 @@ test('discards cache if userOptions change', t => {
228228
});
229229

230230
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');
234235

235236
makeDir.sync(cacheDir);
236237
fs.writeFileSync(depFile, 'module.exports = () => ({})');
237238

238239
const userOptions = {
239-
plugins: ['./plugin.js']
240+
plugins: [depFile]
240241
};
241242
return babelConfigHelper.build(projectDir, cacheDir, userOptions, true)
242243
.then(result => {
@@ -255,8 +256,8 @@ test('updates cached verifier if dependency hashes change', t => {
255256
});
256257

257258
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');
260261

261262
t.plan(1);
262263
return babelConfigHelper.build(projectDir, cacheDir, 'default', true)

test/fixture/no-babel-config/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)