@@ -18,8 +18,6 @@ test('require a .ts file with explicit extension succeeds', async () => {
18
18
strictEqual ( result . code , 0 ) ;
19
19
} ) ;
20
20
21
- // TODO(marco-ippolito) This test should fail because extensionless require
22
- // but it's behaving like a .js file
23
21
test ( 'eval require a .ts file with implicit extension fails' , async ( ) => {
24
22
const result = await spawnPromisified ( process . execPath , [
25
23
'--experimental-strip-types' ,
@@ -30,23 +28,36 @@ test('eval require a .ts file with implicit extension fails', async () => {
30
28
cwd : fixtures . path ( 'typescript/ts' ) ,
31
29
} ) ;
32
30
33
- strictEqual ( result . stderr , '' ) ;
34
- match ( result . stdout , / H e l l o , T y p e S c r i p t ! / ) ;
35
- strictEqual ( result . code , 0 ) ;
31
+ strictEqual ( result . stdout , '' ) ;
32
+ match ( result . stderr , / E r r o r : C a n n o t f i n d m o d u l e / ) ;
33
+ strictEqual ( result . code , 1 ) ;
34
+ } ) ;
35
+
36
+ test ( 'eval require a .cts file with implicit extension fails' , async ( ) => {
37
+ const result = await spawnPromisified ( process . execPath , [
38
+ '--experimental-strip-types' ,
39
+ '--eval' ,
40
+ 'require("./test-cts-typescript")' ,
41
+ '--no-warnings' ,
42
+ ] , {
43
+ cwd : fixtures . path ( 'typescript/ts' ) ,
44
+ } ) ;
45
+
46
+ strictEqual ( result . stdout , '' ) ;
47
+ match ( result . stderr , / E r r o r : C a n n o t f i n d m o d u l e / ) ;
48
+ strictEqual ( result . code , 1 ) ;
36
49
} ) ;
37
50
38
- // TODO(marco-ippolito) This test should fail because extensionless require
39
- // but it's behaving like a .js file
40
51
test ( 'require a .ts file with implicit extension fails' , async ( ) => {
41
52
const result = await spawnPromisified ( process . execPath , [
42
53
'--experimental-strip-types' ,
43
54
'--no-warnings' ,
44
55
fixtures . path ( 'typescript/cts/test-extensionless-require.ts' ) ,
45
56
] ) ;
46
57
47
- strictEqual ( result . stderr , '' ) ;
48
- match ( result . stdout , / H e l l o , T y p e S c r i p t ! / ) ;
49
- strictEqual ( result . code , 0 ) ;
58
+ strictEqual ( result . stdout , '' ) ;
59
+ match ( result . stderr , / E r r o r : C a n n o t f i n d m o d u l e / ) ;
60
+ strictEqual ( result . code , 1 ) ;
50
61
} ) ;
51
62
52
63
test ( 'expect failure of an .mts file with CommonJS syntax' , async ( ) => {
0 commit comments