diff --git a/packages/core/__tests__/cli/watch.test.ts b/packages/core/__tests__/cli/watch.test.ts index d2a4bf37..c5fbd000 100644 --- a/packages/core/__tests__/cli/watch.test.ts +++ b/packages/core/__tests__/cli/watch.test.ts @@ -217,7 +217,9 @@ describe('CLI: watched typechecking', () => { await watch.terminate(); }); - test.skip('reports on errors introduced and cleared in a script with a .gts extension', async () => { + // TODO: Reinstate this; some reason this doesn't work when `--build` flag is omitted; specifically + // it will detect the change and recompile but doesn't see the error. + test.skip('reports on errors introduced and cleared in a script with a .gts extension (without --build)', async () => { project.setGlintConfig({ environment: 'ember-template-imports' }); let code = stripIndent` @@ -249,6 +251,38 @@ describe('CLI: watched typechecking', () => { await watch.terminate(); }); + test('reports on errors introduced and cleared in a script with a .gts extension (with --build)', async () => { + project.setGlintConfig({ environment: 'ember-template-imports' }); + + let code = stripIndent` + export default class MyClass { + private startupTime = new Date().toISOString(); + + public render(): void { + console.log(this.startupTime); + } + } + `; + + project.write('index.gts', code); + + let watch = project.checkWatch({ reject: true, build: true }); + let output = await watch.awaitOutput('Watching for file changes.'); + expect(output).toMatch('Found 0 errors.'); + + project.write('index.gts', code.replace('this.startupTime', 'this.startupTimee')); + + output = await watch.awaitOutput('Watching for file changes.'); + expect(output).toMatch('Found 1 error.'); + + project.write('index.gts', code); + + output = await watch.awaitOutput('Watching for file changes.'); + expect(output).toMatch('Found 0 errors.'); + + await watch.terminate(); + }); + test.skip('reports correct diagnostics given @glint-expect-error and @glint-ignore directives', async () => { project.setGlintConfig({ environment: 'ember-loose' }); diff --git a/test-packages/test-utils/src/project.ts b/test-packages/test-utils/src/project.ts index 1959aae6..c7af4dc0 100644 --- a/test-packages/test-utils/src/project.ts +++ b/test-packages/test-utils/src/project.ts @@ -323,8 +323,11 @@ export class Project { }); } - public checkWatch(options: Options & { flags?: string[] } = {}): Watch { + public checkWatch(options: Options & { flags?: string[], build?: boolean } = {}): Watch { let flags = ['--watch', ...(options.flags ?? [])]; + if (options.build) { + flags.unshift('--build'); + } return new Watch(this.check({ ...options, flags, reject: false })); }