Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ describe('ts-node', function () {
}

expect(err.message).to.contain([
`${join(__dirname, '../tests/throw.ts')}:3`,
`${join(__dirname, '../tests/throw.ts')}:100`,
' bar () { throw new Error(\'this is a demo\') }',
' ^',
'Error: this is a demo'
Expand All @@ -206,7 +206,7 @@ describe('ts-node', function () {
}

expect(err.message).to.contain([
`${join(__dirname, '../tests/throw.ts')}:3`,
`${join(__dirname, '../tests/throw.ts')}:100`,
' bar () { throw new Error(\'this is a demo\') }',
' ^'
].join('\n'))
Expand Down Expand Up @@ -611,7 +611,7 @@ describe('ts-node', function () {
} catch (error) {
expect(error.stack).to.contain([
'Error: this is a demo',
` at Foo.bar (${join(__dirname, '../tests/throw.ts')}:3:18)`
` at Foo.bar (${join(__dirname, '../tests/throw.ts')}:100:18)`
].join('\n'))

done()
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export function create (rawOptions: CreateOptions = {}): Register {
sourceMapSupport.install({
environment: 'node',
retrieveFile (path: string) {
return outputCache.get(path)?.content || ''
return outputCache.get(normalizeSlashes(path))?.content || ''
}
})

Expand Down
97 changes: 97 additions & 0 deletions tests/throw.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,101 @@
// intentional whitespace to prove that sourcemaps are working. Throw should happen on line 100.
// 100 lines is meant to be far more space than the helper functions would take.
class Foo {































































































constructor () { this.bar() }
bar () { throw new Error('this is a demo') }
}
Expand Down