@@ -99,3 +99,99 @@ test("should throw syntax error for invalid typescript", async (t) => {
9999 match ( result . stderr , / a w a i t i s n ' t a l l o w e d i n n o n - a s y n c f u n c t i o n / ) ;
100100 strictEqual ( result . code , 1 ) ;
101101} ) ;
102+
103+ test ( "should work with commonjs typescript files using strip" , async ( ) => {
104+ const result = await spawnPromisified ( process . execPath , [
105+ "--no-warnings" ,
106+ "--import=./dist/register-strip.mjs" ,
107+ fixturesPath ( "commonjs.ts" ) ,
108+ ] ) ;
109+
110+ strictEqual ( result . stderr , "" ) ;
111+ match ( result . stdout , / H e l l o f r o m C o m m o n J S T y p e S c r i p t ! / ) ;
112+ strictEqual ( result . code , 0 ) ;
113+ } ) ;
114+
115+ test ( "should work with commonjs typescript files using transform" , async ( ) => {
116+ const result = await spawnPromisified ( process . execPath , [
117+ "--no-warnings" ,
118+ "--import=./dist/register-transform.mjs" ,
119+ fixturesPath ( "commonjs.ts" ) ,
120+ ] ) ;
121+
122+ strictEqual ( result . stderr , "" ) ;
123+ match ( result . stdout , / H e l l o f r o m C o m m o n J S T y p e S c r i p t ! / ) ;
124+ strictEqual ( result . code , 0 ) ;
125+ } ) ;
126+
127+ test ( "should work with .cts files using strip" , async ( ) => {
128+ const result = await spawnPromisified ( process . execPath , [
129+ "--no-warnings" ,
130+ "--import=./dist/register-strip.mjs" ,
131+ fixturesPath ( "commonjs.cts" ) ,
132+ ] ) ;
133+
134+ strictEqual ( result . stderr , "" ) ;
135+ match ( result . stdout , / H e l l o f r o m C o m m o n J S T y p e S c r i p t \( \. c t s \) ! / ) ;
136+ strictEqual ( result . code , 0 ) ;
137+ } ) ;
138+
139+ test ( "should work with .cts files using transform" , async ( ) => {
140+ const result = await spawnPromisified ( process . execPath , [
141+ "--no-warnings" ,
142+ "--import=./dist/register-transform.mjs" ,
143+ fixturesPath ( "commonjs.cts" ) ,
144+ ] ) ;
145+
146+ strictEqual ( result . stderr , "" ) ;
147+ match ( result . stdout , / H e l l o f r o m C o m m o n J S T y p e S c r i p t \( \. c t s \) ! / ) ;
148+ strictEqual ( result . code , 0 ) ;
149+ } ) ;
150+
151+ test ( "should work with esm typescript files using strip" , async ( ) => {
152+ const result = await spawnPromisified ( process . execPath , [
153+ "--no-warnings" ,
154+ "--import=./dist/register-strip.mjs" ,
155+ fixturesPath ( "esm/esm.ts" ) ,
156+ ] ) ;
157+
158+ strictEqual ( result . stderr , "" ) ;
159+ match ( result . stdout , / H e l l o f r o m E S M T y p e S c r i p t ! / ) ;
160+ strictEqual ( result . code , 0 ) ;
161+ } ) ;
162+
163+ test ( "should work with esm typescript files using transform" , async ( ) => {
164+ const result = await spawnPromisified ( process . execPath , [
165+ "--no-warnings" ,
166+ "--import=./dist/register-transform.mjs" ,
167+ fixturesPath ( "esm/esm.ts" ) ,
168+ ] ) ;
169+
170+ strictEqual ( result . stderr , "" ) ;
171+ match ( result . stdout , / H e l l o f r o m E S M T y p e S c r i p t ! / ) ;
172+ strictEqual ( result . code , 0 ) ;
173+ } ) ;
174+
175+ test ( "should work with .mts files using strip" , async ( ) => {
176+ const result = await spawnPromisified ( process . execPath , [
177+ "--no-warnings" ,
178+ "--import=./dist/register-strip.mjs" ,
179+ fixturesPath ( "esm.mts" ) ,
180+ ] ) ;
181+
182+ strictEqual ( result . stderr , "" ) ;
183+ match ( result . stdout , / H e l l o f r o m E S M T y p e S c r i p t ! / ) ;
184+ strictEqual ( result . code , 0 ) ;
185+ } ) ;
186+
187+ test ( "should work with .mts files using transform" , async ( ) => {
188+ const result = await spawnPromisified ( process . execPath , [
189+ "--no-warnings" ,
190+ "--import=./dist/register-transform.mjs" ,
191+ fixturesPath ( "esm.mts" ) ,
192+ ] ) ;
193+
194+ strictEqual ( result . stderr , "" ) ;
195+ match ( result . stdout , / H e l l o f r o m E S M T y p e S c r i p t ! / ) ;
196+ strictEqual ( result . code , 0 ) ;
197+ } ) ;
0 commit comments