Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cspotcode committed May 3, 2020
1 parent e41ec33 commit a6d1c0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ export function registerAndCreateEsmHooks (opts?: RegisterOptions) {
const { pathname } = parsed
assert(pathname !== null, 'ESM getFormat() hook: URL should never have null pathname')

// If file has .ts or .tsx extension, then ask node how it would treat this file if it were .js
// If file has .ts, .tsx, or .jsx extension, then ask node how it would treat this file if it were .js
const ext = posixPath.extname(pathname!)
if (ext === '.ts' || ext === '.tsx') {
if (ext === '.ts' || ext === '.tsx' || ext === '.jsx') {
return defer(formatUrl({
...parsed,
pathname: pathname + '.js'
Expand Down
4 changes: 2 additions & 2 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,15 +643,15 @@ describe('ts-node', function () {
it('should compile and execute as ESM', (done) => {
exec(`${cmd} index.ts`, { cwd: join(__dirname, '../tests/esm') }, function (err, stdout) {
expect(err).to.equal(null)
expect(stdout).to.equal('foo bar baz\n')
expect(stdout).to.equal('foo bar baz biff\n')

return done()
})
})
it('supports --experimental-specifier-resolution=node', (done) => {
exec(`${cmd} --experimental-specifier-resolution=node index.ts`, { cwd: join(__dirname, '../tests/esm-node-resolver') }, function (err, stdout) {
expect(err).to.equal(null)
expect(stdout).to.equal('foo bar baz\n')
expect(stdout).to.equal('foo bar baz biff\n')

return done()
})
Expand Down

0 comments on commit a6d1c0e

Please sign in to comment.