Skip to content

Commit

Permalink
unskip a few custom extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
machty committed Jul 3, 2024
1 parent 3ef967c commit f4497e1
Showing 1 changed file with 15 additions and 49 deletions.
64 changes: 15 additions & 49 deletions packages/core/__tests__/cli/custom-extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Project } from 'glint-monorepo-test-utils';
import typescript from 'typescript';

Check warning on line 6 in packages/core/__tests__/cli/custom-extensions.test.ts

View workflow job for this annotation

GitHub Actions / Lint

'typescript' is defined but never used. Allowed unused vars must match /^_/u
import semver from 'semver';

Check warning on line 7 in packages/core/__tests__/cli/custom-extensions.test.ts

View workflow job for this annotation

GitHub Actions / Lint

'semver' is defined but never used. Allowed unused vars must match /^_/u

describe.skip('CLI: custom extensions', () => {
describe('CLI: custom extensions', () => {
let project!: Project;
beforeEach(async () => {
project = await Project.create();
Expand All @@ -24,12 +24,15 @@ describe.skip('CLI: custom extensions', () => {

let result = await project.check({ reject: false });

expect(result.exitCode).toBe(1);
expect(stripAnsi(result.stderr)).toMatchInlineSnapshot(`
expect(result.exitCode).not.toBe(0);
expect(stripAnsi(result.stdout)).toMatchInlineSnapshot(`
"index.gts:1:5 - error TS2322: Type 'number' is not assignable to type 'string'.
1 let identifier: string = 123;
1 let identifier: string = 123;let identifier: string = 123;
~~~~~~~~~~
Found 1 error in index.gts:1
"
`);
});
Expand All @@ -55,12 +58,18 @@ describe.skip('CLI: custom extensions', () => {
expect(error.replace(/\r/g, '')).toMatchInlineSnapshot(`
"index.gts:1:5 - error TS2322: Type 'number' is not assignable to type 'string'.
1 let identifier: string = 123;
1 let identifier: string = 123;let identifier: string = 123;
~~~~~~~~~~"
`);
});

describe('external file changes', () => {
// A number of issues with these tests:
//
// - `.gjs` (untyped) file not yet supported
// - extension-less imports are causing issues specifically with `--watch` even though they work in non-watch mode
// - Discussing/tracking here: https://discord.com/channels/1192759067815464990/1192759067815464993/1258084777618178159
// - (I noticed this after changing other.gjs to other.gts)
describe.skip('external file changes', () => {
beforeEach(() => {
project.setGlintConfig({ environment: 'ember-template-imports' });
project.write(
Expand Down Expand Up @@ -123,47 +132,4 @@ describe.skip('CLI: custom extensions', () => {
await watch.terminate();
});
});

describe('module resolution with explicit extensions', () => {
beforeEach(() => {
project.setGlintConfig({ environment: 'ember-template-imports' });
project.write({
'index.gts': stripIndent`
import Greeting from './Greeting.gts';
<template><Greeting /></template>
`,
'Greeting.gts': stripIndent`
<template>Hello!</template>
`,
});
});

test('is illegal by default', async () => {
let result = await project.check({ reject: false });

expect(result.exitCode).toBe(1);
expect(stripAnsi(result.stderr)).toMatchInlineSnapshot(`
"index.gts:1:22 - error TS2307: Cannot find module './Greeting.gts' or its corresponding type declarations.
1 import Greeting from './Greeting.gts';
~~~~~~~~~~~~~~~~
"
`);
});

test.runIf(semver.gte(typescript.version, '5.0.0'))(
'works with `allowImportingTsExtensions: true`',
async () => {
project.updateTsconfig((config) => {
config.compilerOptions ??= {};
config.compilerOptions['allowImportingTsExtensions'] = true;
});

let result = await project.check();

expect(result.exitCode).toBe(0);
expect(result.stderr).toBe('');
},
);
});
});

0 comments on commit f4497e1

Please sign in to comment.