@@ -276,14 +276,30 @@ test.suite('ts-node', (test) => {
276
276
} ) ;
277
277
278
278
test ( 'should work with source maps' , async ( ) => {
279
- const { err } = await exec ( `${ cmd } throw` ) ;
279
+ const { err } = await exec ( `${ cmd } " throw error" ` ) ;
280
280
if ( err === null ) {
281
281
throw new Error ( 'Command was expected to fail, but it succeeded.' ) ;
282
282
}
283
283
284
284
expect ( err . message ) . to . contain (
285
285
[
286
- `${ join ( TEST_DIR , 'throw.ts' ) } :100` ,
286
+ `${ join ( TEST_DIR , 'throw error.ts' ) } :100` ,
287
+ " bar() { throw new Error('this is a demo'); }" ,
288
+ ' ^' ,
289
+ 'Error: this is a demo' ,
290
+ ] . join ( '\n' )
291
+ ) ;
292
+ } ) ;
293
+
294
+ test ( 'should work with source maps in --transpile-only mode' , async ( ) => {
295
+ const { err } = await exec ( `${ cmd } --transpile-only "throw error"` ) ;
296
+ if ( err === null ) {
297
+ throw new Error ( 'Command was expected to fail, but it succeeded.' ) ;
298
+ }
299
+
300
+ expect ( err . message ) . to . contain (
301
+ [
302
+ `${ join ( TEST_DIR , 'throw error.ts' ) } :100` ,
287
303
" bar() { throw new Error('this is a demo'); }" ,
288
304
' ^' ,
289
305
'Error: this is a demo' ,
@@ -292,14 +308,14 @@ test.suite('ts-node', (test) => {
292
308
} ) ;
293
309
294
310
test ( 'eval should work with source maps' , async ( ) => {
295
- const { err } = await exec ( `${ cmd } -pe "import './throw'"` ) ;
311
+ const { err } = await exec ( `${ cmd } -pe "import './throw error '"` ) ;
296
312
if ( err === null ) {
297
313
throw new Error ( 'Command was expected to fail, but it succeeded.' ) ;
298
314
}
299
315
300
316
expect ( err . message ) . to . contain (
301
317
[
302
- `${ join ( TEST_DIR , 'throw.ts' ) } :100` ,
318
+ `${ join ( TEST_DIR , 'throw error .ts' ) } :100` ,
303
319
" bar() { throw new Error('this is a demo'); }" ,
304
320
' ^' ,
305
321
] . join ( '\n' )
@@ -428,11 +444,26 @@ test.suite('ts-node', (test) => {
428
444
} ) ;
429
445
430
446
test ( 'should use source maps with react tsx' , async ( ) => {
431
- const { err, stdout } = await exec ( `${ cmd } throw-react-tsx.tsx` ) ;
447
+ const { err, stdout } = await exec ( `${ cmd } "throw error react tsx.tsx"` ) ;
448
+ expect ( err ) . not . to . equal ( null ) ;
449
+ expect ( err ! . message ) . to . contain (
450
+ [
451
+ `${ join ( TEST_DIR , './throw error react tsx.tsx' ) } :100` ,
452
+ " bar() { throw new Error('this is a demo'); }" ,
453
+ ' ^' ,
454
+ 'Error: this is a demo' ,
455
+ ] . join ( '\n' )
456
+ ) ;
457
+ } ) ;
458
+
459
+ test ( 'should use source maps with react tsx in --transpile-only mode' , async ( ) => {
460
+ const { err, stdout } = await exec (
461
+ `${ cmd } --transpile-only "throw error react tsx.tsx"`
462
+ ) ;
432
463
expect ( err ) . not . to . equal ( null ) ;
433
464
expect ( err ! . message ) . to . contain (
434
465
[
435
- `${ join ( TEST_DIR , './throw- react- tsx.tsx' ) } :100` ,
466
+ `${ join ( TEST_DIR , './throw error react tsx.tsx' ) } :100` ,
436
467
" bar() { throw new Error('this is a demo'); }" ,
437
468
' ^' ,
438
469
'Error: this is a demo' ,
@@ -1016,12 +1047,12 @@ test.suite('ts-node', (test) => {
1016
1047
1017
1048
test ( 'should use source maps' , async ( ) => {
1018
1049
try {
1019
- require ( '../../tests/throw' ) ;
1050
+ require ( '../../tests/throw error ' ) ;
1020
1051
} catch ( error ) {
1021
1052
expect ( error . stack ) . to . contain (
1022
1053
[
1023
1054
'Error: this is a demo' ,
1024
- ` at Foo.bar (${ join ( TEST_DIR , './throw.ts' ) } :100:17)` ,
1055
+ ` at Foo.bar (${ join ( TEST_DIR , './throw error .ts' ) } :100:17)` ,
1025
1056
] . join ( '\n' )
1026
1057
) ;
1027
1058
}
@@ -1175,13 +1206,15 @@ test.suite('ts-node', (test) => {
1175
1206
expect ( stdout ) . to . equal ( 'foo bar baz biff libfoo\n' ) ;
1176
1207
} ) ;
1177
1208
test ( 'should use source maps' , async ( ) => {
1178
- const { err, stdout } = await exec ( `${ cmd } throw.ts` , {
1209
+ const { err, stdout } = await exec ( `${ cmd } " throw error .ts" ` , {
1179
1210
cwd : join ( TEST_DIR , './esm' ) ,
1180
1211
} ) ;
1181
1212
expect ( err ) . not . to . equal ( null ) ;
1182
1213
expect ( err ! . message ) . to . contain (
1183
1214
[
1184
- `${ pathToFileURL ( join ( TEST_DIR , './esm/throw.ts' ) ) } :100` ,
1215
+ `${ pathToFileURL ( join ( TEST_DIR , './esm/throw error.ts' ) )
1216
+ . toString ( )
1217
+ . replace ( / % 2 0 / g, ' ' ) } :100`,
1185
1218
" bar() { throw new Error('this is a demo'); }" ,
1186
1219
' ^' ,
1187
1220
'Error: this is a demo' ,
0 commit comments