Skip to content

Commit

Permalink
feat: Renamed and restructured esm-transpile-only tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Concision committed Aug 12, 2020
1 parent 786903e commit 525b730
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -805,28 +805,26 @@ describe('ts-node', function () {
})
})

describe('support a transpile only mode', () => {
it('should execute successfully with type errors and transpile-only enabled', (done) => {
exec(`${cmd}/transpile-only index.ts`, { cwd: join(__dirname, '../tests/esm-transpile-only') }, function (err, stdout) {
expect(err).to.equal(null)
expect(stdout).to.equal('foo bar baz biff\n')
it('should support transpile only mode via dedicated loader entrypoint', (done) => {
exec(`${cmd}/transpile-only index.ts`, { cwd: join(__dirname, '../tests/esm-transpile-only') }, function (err, stdout) {
expect(err).to.equal(null)
expect(stdout).to.equal('')

return done()
})
return done()
})
it('should throw an error with type errors and transpile-only disabled', (done) => {
exec(`${cmd} index.ts`, { cwd: join(__dirname, '../tests/esm-transpile-only') }, function (err, stdout) {
if (err === null) {
return done('Command was expected to fail, but it succeeded.')
}
})
it('should throw type errors without transpile-only enabled', (done) => {
exec(`${cmd} index.ts`, { cwd: join(__dirname, '../tests/esm-transpile-only') }, function (err, stdout) {
if (err === null) {
return done('Command was expected to fail, but it succeeded.')
}

expect(err.message).to.contain('Unable to compile TypeScript')
expect(err.message).to.match(new RegExp('TS2345: Argument of type \'(?:number|1101)\' is not assignable to parameter of type \'string\'\\.'))
expect(err.message).to.match(new RegExp('TS2322: Type \'(?:"hello world"|string)\' is not assignable to type \'number\'\\.'))
expect(stdout).to.equal('')
expect(err.message).to.contain('Unable to compile TypeScript')
expect(err.message).to.match(new RegExp('TS2345: Argument of type \'(?:number|1101)\' is not assignable to parameter of type \'string\'\\.'))
expect(err.message).to.match(new RegExp('TS2322: Type \'(?:"hello world"|string)\' is not assignable to type \'number\'\\.'))
expect(stdout).to.equal('')

return done()
})
return done()
})
})
}
Expand Down

0 comments on commit 525b730

Please sign in to comment.