Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #1775

Merged
merged 3 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 8 additions & 25 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
matrix:
os: [ubuntu, windows]
# Don't forget to add all new flavors to this list!
flavor: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
flavor: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
include:
# Node 12.15
- flavor: 1
Expand Down Expand Up @@ -95,64 +95,47 @@ jobs:
nodeFlag: 14
typescript: next
typescriptFlag: next
- flavor: 8
node: 14
nodeFlag: 14
typescript: rc
typescriptFlag: rc
# Node 16
# Node 16.11.1
# Earliest version that supports old ESM Loader Hooks API: https://github.com/TypeStrong/ts-node/pull/1522
- flavor: 9
- flavor: 8
node: 16.11.1
nodeFlag: 16_11_1
typescript: latest
typescriptFlag: latest
- flavor: 10
- flavor: 9
node: 16
nodeFlag: 16
typescript: latest
typescriptFlag: latest
downgradeNpm: true
- flavor: 11
- flavor: 10
node: 16
nodeFlag: 16
typescript: 2.7
typescriptFlag: 2_7
downgradeNpm: true
- flavor: 12
- flavor: 11
node: 16
nodeFlag: 16
typescript: next
typescriptFlag: next
downgradeNpm: true
- flavor: 13
node: 16
nodeFlag: 16
typescript: rc
typescriptFlag: rc
downgradeNpm: true
# Node 18
- flavor: 14
- flavor: 12
node: 18
nodeFlag: 18
typescript: latest
typescriptFlag: latest
downgradeNpm: true
- flavor: 15
- flavor: 13
node: 18
nodeFlag: 18
typescript: next
typescriptFlag: next
downgradeNpm: true
- flavor: 16
node: 18
nodeFlag: 18
typescript: rc
typescriptFlag: rc
downgradeNpm: true
# Node nightly
- flavor: 17
- flavor: 14
node: nightly
nodeFlag: nightly
typescript: latest
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"semver": "^7.1.3",
"throat": "^6.0.1",
"typedoc": "^0.22.10",
"typescript": "4.6.4",
"typescript": "4.7.2",
"typescript-json-schema": "^0.53.0",
"util.promisify": "^1.0.1"
},
Expand Down
8 changes: 8 additions & 0 deletions src/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ export const nodeSupportsImportAssertions = semver.gte(
process.version,
'17.1.0'
);
// Node 14.13.0 has a bug where it tries to lex CJS files to discover named exports *before*
// we transform the code.
// In other words, it tries to parse raw TS as CJS and balks at `export const foo =`, expecting to see `exports.foo =`
// This lexing only happens when CJS TS is imported from the ESM loader.
export const nodeSupportsImportingTransformedCjsFromEsm = semver.gte(
process.version,
'14.13.1'
);
/** Supports tsconfig "extends" >= v3.2.0 */
export const tsSupportsTsconfigInheritanceViaNodePackages = semver.gte(
ts.version,
Expand Down
8 changes: 7 additions & 1 deletion src/test/module-node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect, context } from './testlib';
import {
CMD_TS_NODE_WITHOUT_PROJECT_FLAG,
isOneOf,
nodeSupportsImportingTransformedCjsFromEsm,
resetNodeEnvironment,
tsSupportsStableNodeNextNode16,
} from './helpers';
Expand All @@ -18,7 +19,9 @@ type Test = typeof test;

// Declare one test case for each permutations of project configuration
test.suite('TypeScript module=NodeNext and Node16', (test) => {
test.runIf(tsSupportsStableNodeNextNode16);
test.runIf(
tsSupportsStableNodeNextNode16 && nodeSupportsImportingTransformedCjsFromEsm
);

for (const allowJs of [true, false]) {
for (const typecheckMode of [
Expand Down Expand Up @@ -63,6 +66,7 @@ function declareTest(test: Test, testParams: TestParams) {
t.log(stdout);
t.log(stderr);
expect(err).toBe(null);
expect(stdout).toMatch(/done\n$/);
});
}

Expand Down Expand Up @@ -216,6 +220,8 @@ function writeFixturesToFilesystem(name: string, testParams: TestParams) {
}
}

indexFile.content += `console.log('done');\n`;

proj.rm();
proj.write();
return proj;
Expand Down