From 6cdb1f7798befd5c3f63e8894b88aa7465fac981 Mon Sep 17 00:00:00 2001 From: machty Date: Mon, 1 Jul 2024 14:49:08 -0400 Subject: [PATCH] Fix baseline CLI build tests --- packages/core/__tests__/cli/build.test.ts | 15 ++++++++++----- test-packages/test-utils/src/composite-project.ts | 8 ++++++-- test-packages/test-utils/src/project.ts | 4 ++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/core/__tests__/cli/build.test.ts b/packages/core/__tests__/cli/build.test.ts index bd9257c19..c4dba53d4 100644 --- a/packages/core/__tests__/cli/build.test.ts +++ b/packages/core/__tests__/cli/build.test.ts @@ -15,7 +15,7 @@ import { setupCompositeProject, } from 'glint-monorepo-test-utils'; -describe.skip('CLI: single-pass build mode typechecking', () => { +describe('CLI: single-pass build mode typechecking', () => { describe('simple projects using `--build`', () => { let project!: Project; beforeEach(async () => { @@ -52,9 +52,12 @@ describe.skip('CLI: single-pass build mode typechecking', () => { expect(checkResult.exitCode).toBe(0); expect(checkResult.stdout).toEqual(''); expect(checkResult.stderr).toEqual(''); + + // This tests that the `--emitDeclarationOnly` flag within project.build is working. + expect(existsSync(project.filePath('dist/index.gts.js'))).toBe(false); }); - test('rejects a basic project with a template syntax error', async () => { + test.skip('rejects a basic project with a template syntax error', async () => { let code = stripIndent` import '@glint/environment-ember-template-imports'; import Component from '@glimmer/component'; @@ -122,18 +125,20 @@ describe.skip('CLI: single-pass build mode typechecking', () => { let checkResult = await project.build({ reject: false }); expect(checkResult.exitCode).toBe(1); - expect(checkResult.stdout).toEqual(''); - expect(stripAnsi(checkResult.stderr)).toMatchInlineSnapshot(` + expect(stripAnsi(checkResult.stdout)).toMatchInlineSnapshot(` "src/index.gts:16:36 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. 16 The current time is {{truncate this.startupTime 12}}. ~~~~~~~~~~~~~~~~ + + + Found 1 error. " `); }); }); - describe('composite projects', () => { + describe.skip('composite projects', () => { // The basic structure here is designed to give minimal coverage over all // interesting combinations of project invalidation: // diff --git a/test-packages/test-utils/src/composite-project.ts b/test-packages/test-utils/src/composite-project.ts index 9dec73ae7..becd4aa4c 100644 --- a/test-packages/test-utils/src/composite-project.ts +++ b/test-packages/test-utils/src/composite-project.ts @@ -21,9 +21,13 @@ export const BASE_TS_CONFIG = { allowJs: true, checkJs: false, declaration: true, - emitDeclarationOnly: true, + + // commented out for Volar; Volar-ized `tsc` variants (e.g. `vue-tsc` as well as `glint`) + // behave more closely to `tsc`, and it is expected for `noEmit` to be explicitly + // specified in CLI args. + // noEmit: false, + incremental: true, - noEmit: false, noEmitOnError: true, outDir: OUT_DIR, }, diff --git a/test-packages/test-utils/src/project.ts b/test-packages/test-utils/src/project.ts index bbc692f80..e0bb7cb4c 100644 --- a/test-packages/test-utils/src/project.ts +++ b/test-packages/test-utils/src/project.ts @@ -298,7 +298,7 @@ export class Project { // Not sure why this is needed, but in some contexts, `--pretty` is disabled // because TS doesn't detect a TTY setup. // https://github.com/microsoft/TypeScript/blob/c38569655bb151ec351c27032fbd3ef43b8856ba/src/compiler/executeCommandLine.ts#L160 - options.flags = [...options.flags, '--pretty']; + options.flags = [...options.flags, '--noEmit', '--pretty']; return execaNode(require.resolve('@glint/core/bin/glint'), options.flags, { cwd: this.rootDir, @@ -312,7 +312,7 @@ export class Project { } public build(options: Options & { flags?: string[] } = {}, debug = false): ExecaChildProcess { - let flags = ['--build', '--pretty', ...(options.flags ?? [])]; + let flags = ['--build', '--emitDeclarationOnly', '--pretty', ...(options.flags ?? [])]; return execaNode(require.resolve('@glint/core/bin/glint'), flags, { cwd: this.rootDir, nodeOptions: debug ? ['--inspect-brk'] : [],