diff --git a/packages/core/__tests__/cli/build-watch.test.ts b/packages/core/__tests__/cli/build-watch.test.ts index ce0cb49c9..220f2aac4 100644 --- a/packages/core/__tests__/cli/build-watch.test.ts +++ b/packages/core/__tests__/cli/build-watch.test.ts @@ -194,16 +194,16 @@ describe('CLI: watched build mode typechecking', () => { await pauseForTSBuffering(); - project.write(INPUT_SFC, code.replace('this.startupTime', 'this.startupTimee')); - - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput( + INPUT_SFC, + code.replace('this.startupTime', 'this.startupTimee'), + 'Watching for file changes.' + ); expect(output).toMatch('Found 1 error.'); await pauseForTSBuffering(); - project.write(INPUT_SFC, code); - - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput(INPUT_SFC, code, 'Watching for file changes.'); expect(output).toMatch('Found 0 errors.'); await watch.terminate(); @@ -237,9 +237,11 @@ describe('CLI: watched build mode typechecking', () => { await pauseForTSBuffering(); - project.write(INPUT_SFC, code.replace('{{! @glint-nocheck }}', '')); - - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput( + INPUT_SFC, + code.replace('{{! @glint-nocheck }}', ''), + 'Watching for file changes.' + ); expect(output).toMatch('Found 1 error.'); await watch.terminate(); diff --git a/packages/core/__tests__/cli/custom-extensions.test.ts b/packages/core/__tests__/cli/custom-extensions.test.ts index ec01eabd1..27ccd4f13 100644 --- a/packages/core/__tests__/cli/custom-extensions.test.ts +++ b/packages/core/__tests__/cli/custom-extensions.test.ts @@ -81,9 +81,7 @@ describe('CLI: custom extensions', () => { "Cannot find module './other' or its corresponding type declarations." ); - project.write('other.gjs', 'export const foo = 123;'); - - await watch.awaitOutput('Found 0 errors.'); + await watch.writeAndAwaitOutput('other.gjs', 'export const foo = 123;', 'Found 0 errors.'); await watch.terminate(); }); @@ -95,8 +93,11 @@ describe('CLI: custom extensions', () => { expect(output).toMatch('Found 0 errors.'); - project.write('other.gjs', 'export const foo = "hi";'); - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput( + 'other.gjs', + 'export const foo = "hi";', + 'Watching for file changes.' + ); expect(output).toMatch('Found 1 error.'); expect(output).toMatch('TS2362'); diff --git a/packages/core/__tests__/cli/watch.test.ts b/packages/core/__tests__/cli/watch.test.ts index 090266961..fc5b56611 100644 --- a/packages/core/__tests__/cli/watch.test.ts +++ b/packages/core/__tests__/cli/watch.test.ts @@ -154,14 +154,14 @@ describe('CLI: watched typechecking', () => { let output = await watch.awaitOutput('Watching for file changes.'); expect(output).toMatch('Found 0 errors.'); - project.write('index.ts', code.replace('this.startupTime', 'this.startupTimee')); - - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput( + 'index.ts', + code.replace('this.startupTime', 'this.startupTimee'), + 'Watching for file changes.' + ); expect(output).toMatch('Found 1 error.'); - project.write('index.ts', code); - - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput('index.ts', code, 'Watching for file changes.'); expect(output).toMatch('Found 0 errors.'); expect(watch.allOutput).toMatch(/\033c/); // output should include screen reset control sequence @@ -196,19 +196,25 @@ describe('CLI: watched typechecking', () => { let output = await watch.awaitOutput('Watching for file changes.'); expect(output).toMatch('Found 0 errors.'); - project.write('my-component.hbs', template.replace('target', 'tarrget')); - - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput( + 'my-component.hbs', + template.replace('target', 'tarrget'), + 'Watching for file changes.' + ); expect(output).toMatch('Found 1 error.'); - project.write('my-component.hbs', template); - - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput( + 'my-component.hbs', + template, + 'Watching for file changes.' + ); expect(output).toMatch('Found 0 errors.'); - project.write('my-component.hbs', template.replace('@message', '@messagee')); - - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput( + 'my-component.hbs', + template.replace('@message', '@messagee'), + 'Watching for file changes.' + ); expect(output).toMatch('Found 1 error.'); project.remove('my-component.hbs'); @@ -238,14 +244,14 @@ describe('CLI: watched typechecking', () => { 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.'); + output = await watch.writeAndAwaitOutput( + 'index.gts', + code.replace('this.startupTime', 'this.startupTimee'), + 'Watching for file changes.' + ); expect(output).toMatch('Found 1 error.'); - project.write('index.gts', code); - - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput('index.gts', code, 'Watching for file changes.'); expect(output).toMatch('Found 0 errors.'); await watch.terminate(); @@ -278,14 +284,18 @@ describe('CLI: watched typechecking', () => { let output = await watch.awaitOutput('Watching for file changes.'); expect(output).toMatch('Found 0 errors.'); - project.write('my-component.ts', script.replace('// ', '')); - - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput( + 'my-component.ts', + script.replace('// ', ''), + 'Watching for file changes.' + ); expect(output).toMatch('Found 1 error.'); - project.write('my-component.ts', script); - - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput( + 'my-component.ts', + script, + 'Watching for file changes.' + ); expect(output).toMatch('Found 0 errors.'); await watch.terminate(); @@ -316,14 +326,14 @@ describe('CLI: watched typechecking', () => { let output = await watch.awaitOutput('Watching for file changes.'); expect(output).toMatch('Found 0 errors.'); - project.write('index.ts', code.replace('this.startupTime', 'this.startupTimee')); - - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput( + 'index.ts', + code.replace('this.startupTime', 'this.startupTimee'), + 'Watching for file changes.' + ); expect(output).toMatch('Found 1 error.'); - project.write('index.ts', code); - - output = await watch.awaitOutput('Watching for file changes.'); + output = await watch.writeAndAwaitOutput('index.ts', code, 'Watching for file changes.'); expect(output).toMatch('Found 0 errors.'); expect(watch.allOutput).not.toMatch(/\033c/); // output should not include screen reset control sequence