Skip to content

Commit

Permalink
fix tests on node 10
Browse files Browse the repository at this point in the history
  • Loading branch information
cspotcode committed Feb 15, 2021
1 parent 9734642 commit 7d7f76b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.spec.ts
Expand Up @@ -470,8 +470,10 @@ describe('ts-node', function () {
})
})

const preferTsExtsEntrypoint = semver.gte(process.version, '12.0.0') ? 'import-order/compiled' : 'import-order/require-compiled'
it('should import ts before js when --prefer-ts-exts flag is present', function (done) {
exec(`${cmd} --prefer-ts-exts import-order/compiled`, function (err, stdout) {

exec(`${cmd} --prefer-ts-exts ${preferTsExtsEntrypoint}`, function (err, stdout) {
expect(err).to.equal(null)
expect(stdout).to.equal('Hello, TypeScript!\n')

Expand All @@ -480,7 +482,7 @@ describe('ts-node', function () {
})

it('should import ts before js when TS_NODE_PREFER_TS_EXTS env is present', function (done) {
exec(`${cmd} import-order/compiled`, { env: { ...process.env, TS_NODE_PREFER_TS_EXTS: 'true' } }, function (err, stdout) {
exec(`${cmd} ${preferTsExtsEntrypoint}`, { env: { ...process.env, TS_NODE_PREFER_TS_EXTS: 'true' } }, function (err, stdout) {
expect(err).to.equal(null)
expect(stdout).to.equal('Hello, TypeScript!\n')

Expand Down
2 changes: 2 additions & 0 deletions tests/import-order/require-compiled.js
@@ -0,0 +1,2 @@
// indirectly load ./compiled in node < 12 (soon to be end-of-life'd)
require('./compiled')

0 comments on commit 7d7f76b

Please sign in to comment.