Skip to content

Commit 6fb4b8f

Browse files
committed
tests
1 parent 18566b4 commit 6fb4b8f

File tree

7 files changed

+19
-11
lines changed

7 files changed

+19
-11
lines changed

src/index.spec.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ describe('ts-node', function () {
471471
const BIN_EXEC = `"${BIN_PATH}" --project tests/tsconfig-options/tsconfig.json`
472472

473473
it('should override compiler options from env', function (done) {
474-
exec(`${BIN_EXEC} tests/tsconfig-options/log-options.js`, {
474+
exec(`${BIN_EXEC} tests/tsconfig-options/log-options1.js`, {
475475
env: {
476476
...process.env,
477477
TS_NODE_COMPILER_OPTIONS: '{"typeRoots": ["env-typeroots"]}'
@@ -485,35 +485,38 @@ describe('ts-node', function () {
485485
})
486486

487487
it('should use options from `tsconfig.json`', function (done) {
488-
exec(`${BIN_EXEC} tests/tsconfig-options/log-options.js`, function (err, stdout) {
488+
exec(`${BIN_EXEC} tests/tsconfig-options/log-options1.js`, function (err, stdout) {
489489
expect(err).to.equal(null)
490490
const { options, config } = JSON.parse(stdout)
491491
expect(config.options.typeRoots).to.deep.equal([join(__dirname, '../tests/tsconfig-options/tsconfig-typeroots').replace(/\\/g, '/')])
492492
expect(config.options.types).to.deep.equal(['tsconfig-tsnode-types'])
493493
expect(options.pretty).to.equal(undefined)
494494
expect(options.skipIgnore).to.equal(false)
495495
expect(options.transpileOnly).to.equal(true)
496-
expect(options.require).to.deep.equal([join(__dirname, '../tests/tsconfig-options/required.js')])
496+
expect(options.require).to.deep.equal([join(__dirname, '../tests/tsconfig-options/required1.js')])
497497
return done()
498498
})
499499
})
500500

501-
it('should have flags override `tsconfig.json`', function (done) {
502-
exec(`${BIN_EXEC} --skip-ignore --compiler-options "{\\"types\\":[\\"flags-types\\"]}" tests/tsconfig-options/log-options.js`, function (err, stdout) {
501+
it('should have flags override / merge with `tsconfig.json`', function (done) {
502+
exec(`${BIN_EXEC} --skip-ignore --compiler-options "{\\"types\\":[\\"flags-types\\"]}" --require ./tests/tsconfig-options/required2.js tests/tsconfig-options/log-options2.js`, function (err, stdout) {
503503
expect(err).to.equal(null)
504504
const { options, config } = JSON.parse(stdout)
505505
expect(config.options.typeRoots).to.deep.equal([join(__dirname, '../tests/tsconfig-options/tsconfig-typeroots').replace(/\\/g, '/')])
506506
expect(config.options.types).to.deep.equal(['flags-types'])
507507
expect(options.pretty).to.equal(undefined)
508508
expect(options.skipIgnore).to.equal(true)
509509
expect(options.transpileOnly).to.equal(true)
510-
expect(options.require).to.deep.equal([join(__dirname, '../tests/tsconfig-options/required.js')])
510+
expect(options.require).to.deep.equal([
511+
join(__dirname, '../tests/tsconfig-options/required1.js'),
512+
'./tests/tsconfig-options/required2.js'
513+
])
511514
return done()
512515
})
513516
})
514517

515518
it('should have `tsconfig.json` override environment', function (done) {
516-
exec(`${BIN_EXEC} tests/tsconfig-options/log-options.js`, {
519+
exec(`${BIN_EXEC} tests/tsconfig-options/log-options1.js`, {
517520
env: {
518521
...process.env,
519522
TS_NODE_PRETTY: 'true',
@@ -527,7 +530,7 @@ describe('ts-node', function () {
527530
expect(options.pretty).to.equal(true)
528531
expect(options.skipIgnore).to.equal(false)
529532
expect(options.transpileOnly).to.equal(true)
530-
expect(options.require).to.deep.equal([join(__dirname, '../tests/tsconfig-options/required.js')])
533+
expect(options.require).to.deep.equal([join(__dirname, '../tests/tsconfig-options/required1.js')])
531534
return done()
532535
})
533536
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const assert = require('assert')
2-
assert(process.required)
2+
assert(process.required1)
33
const register = process[Symbol.for('ts-node.register.instance')]
44
console.log(JSON.stringify({
55
options: register.options,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const assert = require('assert')
2+
require('./log-options1')
3+
assert(process.required2)

tests/tsconfig-options/required.js

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
process.required1 = true
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require('assert')(process.required1)
2+
process.required2 = true

tests/tsconfig-options/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"types": ["tsconfig-tsnode-types"]
66
},
77
"transpileOnly": true,
8-
"require": ["./required"],
8+
"require": ["./required1"],
99
"skipIgnore": false
1010
},
1111
"compilerOptions": {

0 commit comments

Comments
 (0)