Skip to content

Commit aa212c7

Browse files
authored
Tests: Use clearer project testing commands (#741)
1 parent c9300e5 commit aa212c7

File tree

5 files changed

+48
-45
lines changed

5 files changed

+48
-45
lines changed

packages/core/__tests__/cli/build-watch.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
7878

7979
project.write(INPUT_SFC, code);
8080

81-
let watch = project.buildWatch({ reject: true });
81+
let watch = project.buildDeclarationWatch({ reject: true });
8282
let output = await watch.awaitOutput('Watching for file changes.');
8383
await watch.terminate();
8484

@@ -107,7 +107,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
107107

108108
project.write(INPUT_SFC, code);
109109

110-
let watch = project.buildWatch({ reject: false });
110+
let watch = project.buildDeclarationWatch({ reject: false });
111111
let output = await watch.awaitOutput('Watching for file changes.');
112112

113113
await watch.terminate();
@@ -146,7 +146,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
146146

147147
project.write(INPUT_SFC, code);
148148

149-
let watch = project.buildWatch();
149+
let watch = project.buildDeclarationWatch();
150150
let output = await watch.awaitOutput('Watching for file changes.');
151151

152152
await watch.terminate();
@@ -187,7 +187,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
187187

188188
project.write(INPUT_SFC, code);
189189

190-
let watch = project.buildWatch({ reject: true });
190+
let watch = project.buildDeclarationWatch({ reject: true });
191191

192192
let output = await watch.awaitOutput('Watching for file changes.');
193193
expect(output).toMatch('Found 0 errors.');
@@ -230,7 +230,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
230230

231231
project.write(INPUT_SFC, code);
232232

233-
let watch = project.buildWatch({ reject: true });
233+
let watch = project.buildDeclarationWatch({ reject: true });
234234

235235
let output = await watch.awaitOutput('Watching for file changes.');
236236
expect(output).toMatch('Found 0 errors.');
@@ -329,7 +329,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
329329
});
330330

331331
test('passes when all projects are valid', async () => {
332-
let watch = projects.root.buildWatch({ reject: true });
332+
let watch = projects.root.buildDeclarationWatch({ reject: true });
333333

334334
let output = await watch.awaitOutput('Watching for file changes.');
335335
expect(output).toMatch('Found 0 errors.');
@@ -340,7 +340,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
340340
describe('reports on errors introduced and cleared during the watch', () => {
341341
describe('for template syntax errors', () => {
342342
test('in the root', async () => {
343-
let watch = projects.root.buildWatch({ reject: true });
343+
let watch = projects.root.buildDeclarationWatch({ reject: true });
344344

345345
let output = await watch.awaitOutput('Watching for file changes.');
346346
expect(output).toMatch('Found 0 errors.');
@@ -379,7 +379,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
379379
});
380380

381381
test('in a project with references referenced directly by the root', async () => {
382-
let watch = projects.root.buildWatch({ reject: true });
382+
let watch = projects.root.buildDeclarationWatch({ reject: true });
383383

384384
let output = await watch.awaitOutput('Watching for file changes.');
385385
expect(output).toMatch('Found 0 errors.');
@@ -417,7 +417,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
417417
});
418418

419419
test('in a project transitively referenced by the root', async () => {
420-
let watch = projects.root.buildWatch({ reject: true });
420+
let watch = projects.root.buildDeclarationWatch({ reject: true });
421421

422422
let output = await watch.awaitOutput('Watching for file changes.');
423423
expect(output).toMatch('Found 0 errors.');
@@ -455,7 +455,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
455455

456456
describe('for template type errors', () => {
457457
test('in the root', async () => {
458-
let watch = projects.root.buildWatch({ reject: true });
458+
let watch = projects.root.buildDeclarationWatch({ reject: true });
459459

460460
let output = await watch.awaitOutput('Watching for file changes.');
461461
expect(output).toMatch('Found 0 errors.');
@@ -488,7 +488,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
488488
});
489489

490490
test('in a project with references referenced directly by the root', async () => {
491-
let watch = projects.root.buildWatch({ reject: true });
491+
let watch = projects.root.buildDeclarationWatch({ reject: true });
492492

493493
let output = await watch.awaitOutput('Watching for file changes.');
494494
expect(output).toMatch('Found 0 errors.');
@@ -521,7 +521,7 @@ describe.skip('CLI: watched build mode typechecking', () => {
521521
});
522522

523523
test('in a project transitively referenced by the root', async () => {
524-
let watch = projects.root.buildWatch({ reject: true });
524+
let watch = projects.root.buildDeclarationWatch({ reject: true });
525525

526526
let output = await watch.awaitOutput('Watching for file changes.');
527527
expect(output).toMatch('Found 0 errors.');

packages/core/__tests__/cli/build.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ describe('CLI: single-pass build mode typechecking', () => {
4747

4848
project.write(INPUT_SFC, code);
4949

50-
let checkResult = await project.build({ reject: false });
50+
let checkResult = await project.buildDeclaration({ reject: false });
5151

5252
expect(checkResult.exitCode).toBe(0);
5353
expect(checkResult.stdout).toEqual('');
5454
expect(checkResult.stderr).toEqual('');
5555

56-
// This tests that the `--emitDeclarationOnly` flag within project.build is working.
56+
// This tests that the `--emitDeclarationOnly` flag within project.buildDeclaration is working.
5757
expect(existsSync(project.filePath('dist/index.gts.js'))).toBe(false);
5858
});
5959

@@ -79,7 +79,7 @@ describe('CLI: single-pass build mode typechecking', () => {
7979

8080
project.write(INPUT_SFC, code);
8181

82-
let checkResult = await project.build({ reject: false });
82+
let checkResult = await project.buildDeclaration({ reject: false });
8383

8484
expect(checkResult.exitCode).toBe(1);
8585
expect(checkResult.stdout).toEqual('');
@@ -122,7 +122,7 @@ describe('CLI: single-pass build mode typechecking', () => {
122122

123123
project.write(INPUT_SFC, code);
124124

125-
let checkResult = await project.build({ reject: false });
125+
let checkResult = await project.buildDeclaration({ reject: false });
126126

127127
expect(checkResult.exitCode).toBe(1);
128128
expect(stripAnsi(checkResult.stdout)).toMatchInlineSnapshot(`
@@ -1099,11 +1099,11 @@ describe.skip('CLI: --build --clean', () => {
10991099

11001100
project.write(INPUT_SFC, code);
11011101

1102-
let buildResult = await project.build();
1102+
let buildResult = await project.buildDeclaration();
11031103
expect(buildResult.exitCode).toBe(0);
11041104
expect(existsSync(project.filePath(INDEX_D_TS))).toBe(true);
11051105

1106-
let buildCleanResult = await project.build({ flags: ['--clean'] });
1106+
let buildCleanResult = await project.buildDeclaration({ flags: ['--clean'] });
11071107
expect(buildCleanResult.exitCode).toBe(0);
11081108
expect(existsSync(project.filePath(INDEX_D_TS))).toBe(false);
11091109
});
@@ -1193,13 +1193,13 @@ describe.skip('CLI: --build --force', () => {
11931193

11941194
project.write(INPUT_SFC, code);
11951195

1196-
let buildResult = await project.build();
1196+
let buildResult = await project.buildDeclaration();
11971197
expect(buildResult.exitCode).toBe(0);
11981198
let indexDTs = project.filePath(INDEX_D_TS);
11991199
expect(existsSync(indexDTs)).toBe(true);
12001200
let firstStat = statSync(indexDTs);
12011201

1202-
let buildCleanResult = await project.build({ flags: ['--force'] });
1202+
let buildCleanResult = await project.buildDeclaration({ flags: ['--force'] });
12031203
expect(buildCleanResult.exitCode).toBe(0);
12041204
let exists = existsSync(indexDTs);
12051205
expect(exists).toBe(true);
@@ -1309,7 +1309,7 @@ describe.skip('CLI: --build --dry', () => {
13091309
});
13101310

13111311
test('when no build has occurred', async () => {
1312-
let buildResult = await project.build({ flags: ['--dry'] });
1312+
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
13131313
expect(buildResult.exitCode).toBe(0);
13141314
expect(stripAnsi(buildResult.stdout)).toMatch(
13151315
`A non-dry build would build project '${project.filePath('tsconfig.json')}'`,
@@ -1319,11 +1319,11 @@ describe.skip('CLI: --build --dry', () => {
13191319

13201320
describe('when the project has been built', () => {
13211321
beforeEach(async () => {
1322-
await project.build();
1322+
await project.buildDeclaration();
13231323
});
13241324

13251325
test('when there are no changes', async () => {
1326-
let buildResult = await project.build({ flags: ['--dry'] });
1326+
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
13271327
expect(buildResult.exitCode).toBe(0);
13281328
expect(stripAnsi(buildResult.stdout)).toMatch(
13291329
`Project '${project.filePath('tsconfig.json')}' is up to date`,
@@ -1352,7 +1352,7 @@ describe.skip('CLI: --build --dry', () => {
13521352

13531353
project.write(INPUT_SFC, code);
13541354

1355-
let buildResult = await project.build({ flags: ['--dry'] });
1355+
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
13561356
expect(buildResult.exitCode).toBe(0);
13571357
expect(stripAnsi(buildResult.stdout)).toMatch(
13581358
`A non-dry build would build project '${project.filePath('tsconfig.json')}'`,
@@ -1393,7 +1393,7 @@ describe.skip('CLI: --build --dry', () => {
13931393
});
13941394

13951395
test('when no build has occurred', async () => {
1396-
let buildResult = await project.build({ flags: ['--dry'] });
1396+
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
13971397
expect(buildResult.exitCode).toBe(0);
13981398
expect(stripAnsi(buildResult.stdout)).toMatch(
13991399
`A non-dry build would build project '${project.filePath('tsconfig.json')}'`,
@@ -1403,11 +1403,11 @@ describe.skip('CLI: --build --dry', () => {
14031403

14041404
describe('when the project has been built', () => {
14051405
beforeEach(async () => {
1406-
await project.build();
1406+
await project.buildDeclaration();
14071407
});
14081408

14091409
test('when there are no changes', async () => {
1410-
let buildResult = await project.build({ flags: ['--dry'] });
1410+
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
14111411
expect(buildResult.exitCode).toBe(0);
14121412
expect(stripAnsi(buildResult.stdout)).toMatch(
14131413
`Project '${project.filePath('tsconfig.json')}' is up to date`,
@@ -1431,7 +1431,7 @@ describe.skip('CLI: --build --dry', () => {
14311431
`;
14321432
project.write(INPUT_SCRIPT, backingClass);
14331433

1434-
let buildResult = await project.build({ flags: ['--dry'] });
1434+
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
14351435
expect(buildResult.exitCode).toBe(0);
14361436
expect(stripAnsi(buildResult.stdout)).toMatch(
14371437
`A non-dry build would build project '${project.filePath('tsconfig.json')}'`,
@@ -1447,7 +1447,7 @@ describe.skip('CLI: --build --dry', () => {
14471447

14481448
project.write(INPUT_TEMPLATE, template);
14491449

1450-
let buildResult = await project.build({ flags: ['--dry'] });
1450+
let buildResult = await project.buildDeclaration({ flags: ['--dry'] });
14511451
expect(buildResult.exitCode).toBe(0);
14521452
expect(stripAnsi(buildResult.stdout)).toMatch(
14531453
`A non-dry build would build project '${project.filePath('tsconfig.json')}'`,

packages/core/__tests__/cli/custom-extensions.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe.skip('CLI: custom extensions', () => {
4040
project.setGlintConfig({ environment: 'ember-template-imports' });
4141
project.write('index.gts', code);
4242

43-
let watch = project.watch();
43+
let watch = project.checkWatch();
4444
let output = await watch.awaitOutput('Watching for file changes.');
4545

4646
await watch.terminate();
@@ -73,7 +73,7 @@ describe.skip('CLI: custom extensions', () => {
7373
});
7474

7575
test('adding a missing module', async () => {
76-
let watch = project.watch();
76+
let watch = project.checkWatch();
7777
let output = await watch.awaitOutput('Watching for file changes.');
7878

7979
expect(output).toMatch('Found 1 error.');
@@ -90,7 +90,7 @@ describe.skip('CLI: custom extensions', () => {
9090
test('changing an imported module', async () => {
9191
project.write('other.gjs', 'export const foo = 123;');
9292

93-
let watch = project.watch();
93+
let watch = project.checkWatch();
9494
let output = await watch.awaitOutput('Watching for file changes.');
9595

9696
expect(output).toMatch('Found 0 errors.');
@@ -107,7 +107,7 @@ describe.skip('CLI: custom extensions', () => {
107107
test('removing an imported module', async () => {
108108
project.write('other.gjs', 'export const foo = 123;');
109109

110-
let watch = project.watch();
110+
let watch = project.checkWatch();
111111
let output = await watch.awaitOutput('Watching for file changes.');
112112

113113
expect(output).toMatch('Found 0 errors.');

packages/core/__tests__/cli/watch.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('CLI: watched typechecking', () => {
3434

3535
project.write('index.gts', code);
3636

37-
let watch = project.watch({ reject: true });
37+
let watch = project.checkWatch({ reject: true });
3838
let output = await watch.awaitOutput('Watching for file changes.');
3939

4040
await watch.terminate();
@@ -62,7 +62,7 @@ describe('CLI: watched typechecking', () => {
6262

6363
project.write('index.gts', code);
6464

65-
let watch = project.watch();
65+
let watch = project.checkWatch();
6666
let output = await watch.awaitOutput('Watching for file changes.');
6767

6868
await watch.terminate();
@@ -105,7 +105,7 @@ describe('CLI: watched typechecking', () => {
105105

106106
project.write('index.gts', code);
107107

108-
let watch = project.watch();
108+
let watch = project.checkWatch();
109109
let output = await watch.awaitOutput('Watching for file changes.');
110110

111111
await watch.terminate();
@@ -149,7 +149,7 @@ describe('CLI: watched typechecking', () => {
149149

150150
project.write('index.gts', code);
151151

152-
let watch = project.watch({ reject: true });
152+
let watch = project.checkWatch({ reject: true });
153153

154154
let output = await watch.awaitOutput('Watching for file changes.');
155155
expect(output).toMatch('Found 0 errors.');
@@ -191,7 +191,7 @@ describe('CLI: watched typechecking', () => {
191191

192192
project.write('my-component.ts', script);
193193

194-
let watch = project.watch({ reject: true });
194+
let watch = project.checkWatch({ reject: true });
195195

196196
let output = await watch.awaitOutput('Watching for file changes.');
197197
expect(output).toMatch('Found 0 errors.');
@@ -234,7 +234,7 @@ describe('CLI: watched typechecking', () => {
234234

235235
project.write('index.gts', code);
236236

237-
let watch = project.watch({ reject: true });
237+
let watch = project.checkWatch({ reject: true });
238238
let output = await watch.awaitOutput('Watching for file changes.');
239239
expect(output).toMatch('Found 0 errors.');
240240

@@ -273,7 +273,7 @@ describe('CLI: watched typechecking', () => {
273273
project.write('my-component.ts', script);
274274
project.write('my-component.hbs', template);
275275

276-
let watch = project.watch();
276+
let watch = project.checkWatch();
277277

278278
let output = await watch.awaitOutput('Watching for file changes.');
279279
expect(output).toMatch('Found 0 errors.');
@@ -311,7 +311,7 @@ describe('CLI: watched typechecking', () => {
311311

312312
project.write('index.gts', code);
313313

314-
let watch = project.watch({ flags: ['--preserveWatchOutput'], reject: true });
314+
let watch = project.checkWatch({ flags: ['--preserveWatchOutput'], reject: true });
315315

316316
let output = await watch.awaitOutput('Watching for file changes.');
317317
expect(output).toMatch('Found 0 errors.');

test-packages/test-utils/src/project.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,15 @@ export class Project {
306306
});
307307
}
308308

309-
public watch(options: Options & { flags?: string[] } = {}): Watch {
309+
public checkWatch(options: Options & { flags?: string[] } = {}): Watch {
310310
let flags = ['--watch', ...(options.flags ?? [])];
311311
return new Watch(this.check({ ...options, flags, reject: false }));
312312
}
313313

314-
public build(options: Options & { flags?: string[] } = {}, debug = false): ExecaChildProcess {
314+
public buildDeclaration(
315+
options: Options & { flags?: string[] } = {},
316+
debug = false,
317+
): ExecaChildProcess {
315318
let flags = ['--build', '--emitDeclarationOnly', '--pretty', ...(options.flags ?? [])];
316319
return execaNode(require.resolve('@glint/core/bin/glint'), flags, {
317320
cwd: this.rootDir,
@@ -320,9 +323,9 @@ export class Project {
320323
});
321324
}
322325

323-
public buildWatch(options: Options & { flags?: string[] } = {}): Watch {
326+
public buildDeclarationWatch(options: Options & { flags?: string[] } = {}): Watch {
324327
let flags = ['--watch', ...(options.flags ?? [])];
325-
return new Watch(this.build({ ...options, flags, reject: false }));
328+
return new Watch(this.buildDeclaration({ ...options, flags, reject: false }));
326329
}
327330
}
328331

0 commit comments

Comments
 (0)