Skip to content

Commit 9d61f96

Browse files
committed
Split build and test tests
1 parent 3b6d6d4 commit 9d61f96

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

tests/smoke-tests/defaults.test.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import path, { join } from 'node:path';
2+
import fs from 'node:fs/promises';
23

34
import tmp from 'tmp-promise';
45
let localEmberCli = require.resolve('ember-cli/bin/ember');
@@ -17,6 +18,14 @@ import {
1718
} from '../helpers.js';
1819
import { existsSync } from 'node:fs';
1920

21+
/**
22+
* NOTE: tests run sequentially
23+
* we need to manually specify "concurrent" to run them in parallel
24+
*
25+
* https://vitest.dev/guide/features.html#running-tests-concurrently
26+
*
27+
* This is important because we delete stuff in one test that was created in another
28+
*/
2029
for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) {
2130
describe(`defaults with ${packageManager}`, () => {
2231
let tmpDir: string;
@@ -94,7 +103,17 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) {
94103
expect(exitCode).toEqual(0);
95104
});
96105

97-
it('build and test', async () => {
106+
it('build', async () => {
107+
let buildResult = await execa({ cwd: addonDir })`${packageManager} run build`;
108+
109+
expect(buildResult.exitCode).toEqual(0);
110+
111+
let contents = await dirContents(join(addonDir, 'dist'));
112+
113+
expect(contents).to.deep.equal(['_app_', 'components', 'index.js', 'index.js.map']);
114+
});
115+
116+
it('lint:fix', () => {
98117
let addonFixture = fixturify.readSync('./fixtures/addon');
99118
fixturify.writeSync(join(addonDir, 'src'), addonFixture);
100119

@@ -108,16 +127,13 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) {
108127
let { exitCode } = await execa({ cwd: addonDir })`${packageManager} run lint:fix`;
109128

110129
expect(exitCode).toEqual(0);
130+
});
111131

112-
let buildResult = await execa({ cwd: addonDir })`${packageManager} run build`;
113-
114-
expect(buildResult.exitCode).toEqual(0);
115-
116-
let contents = await dirContents(join(addonDir, 'dist'));
117-
118-
expect(contents).to.deep.equal(['_app_', 'components', 'index.js', 'index.js.map']);
132+
it('test', async () => {
133+
// It's important that we ensure that dist directory is empty for this test, because
134+
await fs.rm(join(addonDir, 'dist'), { recursive: true, force: true });
119135

120-
let testResult = await await execa({ cwd: addonDir })`${packageManager} run test`;
136+
let testResult = await execa({ cwd: addonDir })`${packageManager} run test`;
121137

122138
expect(testResult.exitCode).toEqual(0);
123139

0 commit comments

Comments
 (0)