diff --git a/src/index.spec.ts b/src/index.spec.ts index cfb7f4ffe..725bb8b1d 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -340,12 +340,36 @@ describe('ts-node', function () { }) }) - it('issue #884', function (done) { - exec(`node "${BIN_PATH}" --project tests/issue-884/tsconfig.json tests/issue-884`, function (err, stdout) { - expect(err).to.equal(null) - expect(stdout).to.equal('') + describe('issue #884', function () { + it('should compile', function (done) { + exec(`node "${BIN_PATH}" --project tests/issue-884/tsconfig.json tests/issue-884`, function (err, stdout) { + expect(err).to.equal(null) + expect(stdout).to.equal('') - return done() + return done() + }) + }) + }) + + describe('issue #986', function () { + it('should not compile', function (done) { + exec(`node "${BIN_PATH}" --project tests/issue-986/tsconfig.json tests/issue-986`, function (err, stdout, stderr) { + expect(err).not.to.equal(null) + expect(stderr).to.contain('Cannot find name \'TEST\'') // TypeScript error. + expect(stdout).to.equal('') + + return done() + }) + }) + + it('should compile with `--files`', function (done) { + exec(`node "${BIN_PATH}" --files --project tests/issue-986/tsconfig.json tests/issue-986`, function (err, stdout, stderr) { + expect(err).not.to.equal(null) + expect(stderr).to.contain('ReferenceError: TEST is not defined') // Runtime error. + expect(stdout).to.equal('') + + return done() + }) }) }) diff --git a/tests/issue-986/index.ts b/tests/issue-986/index.ts new file mode 100644 index 000000000..fb8e23051 --- /dev/null +++ b/tests/issue-986/index.ts @@ -0,0 +1 @@ +console.log(TEST) diff --git a/tests/issue-986/tsconfig.json b/tests/issue-986/tsconfig.json new file mode 100644 index 000000000..28900bb1b --- /dev/null +++ b/tests/issue-986/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "module": "CommonJS" + } +} diff --git a/tests/issue-986/types.ts b/tests/issue-986/types.ts new file mode 100644 index 000000000..88473dfa4 --- /dev/null +++ b/tests/issue-986/types.ts @@ -0,0 +1 @@ +declare const TEST: string