Skip to content

Commit 1737e4c

Browse files
committed
Fix tests so that its easier to understand what is using fixtures and what isn't
1 parent 9207979 commit 1737e4c

2 files changed

Lines changed: 35 additions & 29 deletions

File tree

tests/fixtures/addon/components/template-import.gjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default class TemplateImport extends Component {
55
<template>
66
Hello from a GJS file
77

8-
<button {{on "click" this.saySomething}}></button>
8+
<button {{on "click" this.saySomething}} type="button"></button>
99
</template>
1010

1111
saySomething() {

tests/smoke-tests/defaults.test.ts

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from 'node:fs/promises';
33

44
import tmp from 'tmp-promise';
55
let localEmberCli = require.resolve('ember-cli/bin/ember');
6-
import { beforeAll, describe, expect, it } from 'vitest';
6+
import { beforeEach, beforeAll, describe, expect, it } from 'vitest';
77
import { execa } from 'execa';
88
import fixturify from 'fixturify';
99

@@ -103,50 +103,56 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) {
103103
expect(exitCode).toEqual(0);
104104
});
105105

106-
it('build', async () => {
107-
let buildResult = await execa({ cwd: addonDir })`${packageManager} run build`;
106+
it('lint:fix with no fixtures', async () => {
107+
let { exitCode } = await execa({ cwd: addonDir })`${packageManager} run lint:fix`;
108108

109-
expect(buildResult.exitCode).toEqual(0);
109+
expect(exitCode).toEqual(0);
110+
});
110111

111-
let contents = await dirContents(join(addonDir, 'dist'));
112+
describe('with fixture', () => {
113+
beforeEach(async () => {
114+
let addonFixture = fixturify.readSync('./fixtures/addon');
115+
fixturify.writeSync(join(addonDir, 'src'), addonFixture);
112116

113-
expect(contents).to.deep.equal(['_app_', 'components', 'index.js', 'index.js.map']);
114-
});
117+
let testFixture = fixturify.readSync('./fixtures/rendering-tests');
118+
fixturify.writeSync(join(addonDir, 'tests/rendering'), testFixture);
119+
});
115120

116-
it('lint:fix', async () => {
117-
let addonFixture = fixturify.readSync('./fixtures/addon');
118-
fixturify.writeSync(join(addonDir, 'src'), addonFixture);
121+
it('lint:fix', async () => {
122+
let { exitCode } = await execa({ cwd: addonDir })`${packageManager} run lint:fix`;
119123

120-
let testFixture = fixturify.readSync('./fixtures/rendering-tests');
121-
fixturify.writeSync(join(addonDir, 'tests/rendering'), testFixture);
124+
expect(exitCode).toEqual(0);
125+
});
122126

123-
// Ensure that we have no lint errors.
124-
// It's important to keep this along with the tests,
125-
// so that we can have confidence that the lints aren't destructively changing
126-
// the files in a way that would break consumers
127-
let { exitCode } = await execa({ cwd: addonDir })`${packageManager} run lint:fix`;
127+
it('build', async () => {
128+
let buildResult = await execa({ cwd: addonDir })`${packageManager} run build`;
128129

129-
expect(exitCode).toEqual(0);
130-
});
130+
expect(buildResult.exitCode).toEqual(0);
131+
132+
let contents = await dirContents(join(addonDir, 'dist'));
133+
134+
expect(contents).to.deep.equal(['_app_', 'components', 'index.js', 'index.js.map']);
135+
});
131136

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 });
137+
it('test', async () => {
138+
// It's important that we ensure that dist directory is empty for this test, because
139+
await fs.rm(join(addonDir, 'dist'), { recursive: true, force: true });
135140

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

138-
expect(testResult.exitCode).toEqual(0);
143+
expect(testResult.exitCode).toEqual(0);
139144

140-
expect(testResult.stdout).includes(
141-
`# tests 2
145+
expect(testResult.stdout).includes(
146+
`# tests 2
142147
# pass 2
143148
# skip 0
144149
# todo 0
145150
# fail 0
146151
147152
# ok`,
148-
testResult.stdout,
149-
);
153+
testResult.stdout,
154+
);
155+
});
150156
});
151157
});
152158
}

0 commit comments

Comments
 (0)