Skip to content

Commit

Permalink
Fix tests (#1775)
Browse files Browse the repository at this point in the history
* Remove ts rc from test matrix

* upgrade typescript version to 4.7

* skip NodeNext tests on incompatible node versions
  • Loading branch information
cspotcode committed May 26, 2022
1 parent 78d103f commit b3dd3f2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 30 deletions.
33 changes: 8 additions & 25 deletions .github/workflows/continuous-integration.yml
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
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
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
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

0 comments on commit b3dd3f2

Please sign in to comment.