@@ -41,7 +41,7 @@ fs.removeSync(join(tmpDir, 'fixture'))
4141fs . copySync ( join ( __dirname , 'fixture' ) , scriptsDir )
4242describe ( 'ts-node-dev' , function ( ) {
4343 this . timeout ( 5000 )
44- it ( 'It should restart on file change' , async ( ) => {
44+ it ( 'should restart on file change' , async ( ) => {
4545 const ps = spawnTsNodeDev ( '--respawn --poll simple.ts' )
4646 await ps . waitForLine ( / v 1 / )
4747 setTimeout ( ( ) => replaceText ( 'dep.ts' , 'v1' , 'v2' ) , 250 )
@@ -52,7 +52,7 @@ describe('ts-node-dev', function () {
5252 await replaceText ( 'dep.ts' , 'v2' , 'v1' )
5353 } )
5454
55- it ( 'It allow watch arbitrary folder/file' , async ( ) => {
55+ it ( 'allow watch arbitrary folder/file' , async ( ) => {
5656 const ps = spawnTsNodeDev ( '--respawn --watch folder,folder2 simple.ts' )
5757 await ps . waitForLine ( / v 1 / )
5858 setTimeout ( ( ) => touch ( join ( scriptsDir , 'folder/some-file' ) ) , 250 )
@@ -61,7 +61,7 @@ describe('ts-node-dev', function () {
6161 await ps . exit ( )
6262 } )
6363
64- it ( 'It should report an error on start' , async ( ) => {
64+ it ( 'should report an error on start' , async ( ) => {
6565 const ps = spawnTsNodeDev ( '--respawn with-error.ts' )
6666 await ps . waitForLine ( / [ E R R O R ] / )
6767 const out = ps . getStdout ( )
@@ -80,7 +80,7 @@ describe('ts-node-dev', function () {
8080 await replaceText ( 'with-error.ts' , '1' , `'1'` )
8181 } )
8282
83- it ( 'It should report an error with --log-error and continue to work' , async ( ) => {
83+ it ( 'should report an error with --log-error and continue to work' , async ( ) => {
8484 const ps = spawnTsNodeDev ( '--respawn --log-error with-error.ts' )
8585 await ps . waitForErrorLine ( / e r r o r / )
8686
@@ -96,9 +96,8 @@ describe('ts-node-dev', function () {
9696 await replaceText ( 'with-error.ts' , '1' , `'1'` )
9797 } )
9898
99- it ( 'It should restart on adding not imported module' , async ( ) => {
99+ it ( 'should restart on adding not imported module' , async ( ) => {
100100 const ps = spawnTsNodeDev ( '--respawn --error-recompile with-error.ts' , {
101- // stdout: true,
102101 env : {
103102 TS_NODE_DEV_ERROR_RECOMPILE_TIMEOUT : 50 ,
104103 } ,
@@ -113,13 +112,12 @@ describe('ts-node-dev', function () {
113112 await replaceText ( 'dep-ts-error.ts' , 'string' , 'number' )
114113 } )
115114
116- const notFoundSource = `export const fn = (x: number ) => {
117- return 'v1'
118- }
119- `
120- it ( 'It recompiles file on error and restarts' , async ( ) => {
115+ it ( 'should recompile module on error and restarts' , async ( ) => {
116+ const notFoundSource = `export const fn = (x: number) => {
117+ return 'v1'
118+ }
119+ `
121120 const ps = spawnTsNodeDev ( '--respawn --error-recompile with-not-found.ts' , {
122- //stdout: true,
123121 env : {
124122 TS_NODE_DEV_ERROR_RECOMPILE_TIMEOUT : 20 ,
125123 } ,
@@ -134,12 +132,11 @@ describe('ts-node-dev', function () {
134132 await removeFile ( 'not-found.ts' )
135133 } )
136134
137- it ( 'It handles allowJs option and loads JS modules' , async ( ) => {
135+ it ( 'should handle allowJs option and compile JS modules' , async ( ) => {
138136 const cOptions = { allowJs : true , esModuleInterop : false }
139137 const ps = spawnTsNodeDev (
140138 [
141139 `--respawn` ,
142- `--compiler ttypescript` ,
143140 `--compiler-options=${ JSON . stringify ( cOptions ) } ` ,
144141 `js-module.js` ,
145142 ] . join ( ' ' )
@@ -149,7 +146,14 @@ describe('ts-node-dev', function () {
149146 await ps . exit ( )
150147 } )
151148
152- it ( 'It handles resolveJsonModule option and loads JSON modules' , async ( ) => {
149+ it ( 'should handle -r esm option and load JS modules' , async ( ) => {
150+ const ps = spawnTsNodeDev ( [ `--respawn` , `-r esm` , `js-module.js` ] . join ( ' ' ) )
151+ await ps . waitForLine ( / J S M O D U L E / )
152+ t . ok ( true , 'ok' )
153+ await ps . exit ( )
154+ } )
155+
156+ it ( 'should handle resolveJsonModule option and load JSON modules' , async ( ) => {
153157 const cOptions = { resolveJsonModule : true }
154158 const ps = spawnTsNodeDev (
155159 [
@@ -164,43 +168,47 @@ describe('ts-node-dev', function () {
164168 await ps . exit ( )
165169 } )
166170
167- it ( 'It should not allow --script-mode and --dir together' , async ( ) => {
168- const ps = spawnTsNodeDev (
169- [ `--script-mode` , `--dir folder` , `simple.ts` ] . join ( ' ' )
170- )
171- await ps . waitForErrorLine ( / S c r i p t m o d e c a n n o t b e c o m b i n e d w i t h ` - - d i r ` / )
172- t . ok ( true , 'ok' )
173- await ps . exit ( )
174- } )
171+ describe ( '--dir and --script-mode flags' , ( ) => {
172+ it ( 'should not allow --script-mode and --dir together' , async ( ) => {
173+ const ps = spawnTsNodeDev (
174+ [ `--script-mode` , `--dir folder` , `simple.ts` ] . join ( ' ' )
175+ )
176+ await ps . waitForErrorLine ( / S c r i p t m o d e c a n n o t b e c o m b i n e d w i t h ` - - d i r ` / )
177+ t . ok ( true , 'ok' )
178+ await ps . exit ( )
179+ } )
175180
176- it ( 'It should use the tsconfig at --dir when defined' , async ( ) => {
177- const ps = spawnTsNodeDev ( [ `--dir dir-test` , `dir-test/index.ts` ] . join ( ' ' ) )
178- await ps . waitForLine ( / \{ h e l l o : ' w o r l d ' \} / )
179- t . ok ( true , 'ok' )
180- await ps . exit ( )
181- } )
181+ it ( 'should use the tsconfig at --dir when defined' , async ( ) => {
182+ const ps = spawnTsNodeDev (
183+ [ `--dir dir-test` , `dir-test/index.ts` ] . join ( ' ' )
184+ )
185+ await ps . waitForLine ( / \{ h e l l o : ' w o r l d ' \} / )
186+ t . ok ( true , 'ok' )
187+ await ps . exit ( )
188+ } )
182189
183- it ( 'It should use the tsconfig at --script-mode when defined' , async ( ) => {
184- const ps = spawnTsNodeDev ( [ `-s` , `dir-test/index.ts` ] . join ( ' ' ) )
185- await ps . waitForLine ( / \{ h e l l o : ' w o r l d ' \} / )
186- t . ok ( true , 'ok' )
187- await ps . exit ( )
188- } )
190+ it ( 'should use the tsconfig at --script-mode when defined' , async ( ) => {
191+ const ps = spawnTsNodeDev ( [ `-s` , `dir-test/index.ts` ] . join ( ' ' ) )
192+ await ps . waitForLine ( / \{ h e l l o : ' w o r l d ' \} / )
193+ t . ok ( true , 'ok' )
194+ await ps . exit ( )
195+ } )
189196
190- it ( 'It should fail if not using --dir or --script-mode on dir-test/index.ts' , async ( ) => {
191- const cOptions = { allowJs : true , esModuleInterop : false }
192- const ps = spawnTsNodeDev (
193- [
194- `--compiler-options=${ JSON . stringify ( cOptions ) } ` ,
195- `dir-test/index.ts` ,
196- ] . join ( ' ' )
197- )
198- await ps . waitForLine ( / h a s n o d e f a u l t e x p o r t ./ )
199- t . ok ( true , 'ok' )
200- await ps . exit ( )
197+ it ( 'should fail if not using --dir or --script-mode on dir-test/index.ts' , async ( ) => {
198+ const cOptions = { allowJs : true , esModuleInterop : false }
199+ const ps = spawnTsNodeDev (
200+ [
201+ `--compiler-options=${ JSON . stringify ( cOptions ) } ` ,
202+ `dir-test/index.ts` ,
203+ ] . join ( ' ' )
204+ )
205+ await ps . waitForLine ( / h a s n o d e f a u l t e x p o r t ./ )
206+ t . ok ( true , 'ok' )
207+ await ps . exit ( )
208+ } )
201209 } )
202210
203- it ( 'It allows to use TS Transformers ' , async ( ) => {
211+ it ( 'should allow to use custom TS transformers ' , async ( ) => {
204212 const cOptions = { plugins : [ { transform : 'ts-nameof' , type : 'raw' } ] }
205213 const ps = spawnTsNodeDev (
206214 [
@@ -230,38 +238,19 @@ describe('ts-node-dev', function () {
230238 await ps . exit ( )
231239 } )
232240
233- describe ( 'It should --prefer-ts' , async ( ) => {
234- it ( 'Should require JS by default' , async ( ) => {
235- const ps = spawnTsNodeDev (
236- [
237- `--respawn` ,
238- //`--prefer-ts-exts`,
239- `prefer/prefer.js` ,
240- ] . join ( ' ' )
241- )
242- await ps . waitForLine ( / P R E F E R D E P J S / )
243- await ps . waitForLine ( / P R E F E R J S / )
244- await ps . exit ( )
245- t . ok ( true )
246- } )
247- it ( 'Should require JS deps by default' , async ( ) => {
248- const ps = spawnTsNodeDev (
249- [
250- `--respawn` ,
251- //`--prefer-ts`,
252- `prefer/prefer` ,
253- ] . join ( ' ' )
254- ) //.turnOnOutput()
241+ describe ( '--prefer-ts-exts flag' , async ( ) => {
242+ it ( 'should require existing JS modules by default' , async ( ) => {
243+ const ps = spawnTsNodeDev ( [ `--respawn` , `prefer/prefer` ] . join ( ' ' ) )
255244 await ps . waitForLine ( / P R E F E R D E P J S / )
256245 await ps . waitForLine ( / P R E F E R T S / )
257246 await ps . exit ( )
258247 t . ok ( true )
259248 } )
260249
261- it ( 'Use require all TS with --ts-prefer' , async ( ) => {
250+ it ( 'should require TS modules with --ts-prefer-exts ' , async ( ) => {
262251 const ps = spawnTsNodeDev (
263252 [ `--respawn` , `--prefer-ts-exts` , `prefer/prefer` ] . join ( ' ' )
264- ) //.turnOnOutput()
253+ )
265254 await ps . waitForLine ( / P R E F E R D E P T S / )
266255 await ps . waitForLine ( / P R E F E R T S / )
267256
@@ -278,7 +267,7 @@ describe('ts-node-dev', function () {
278267 } )
279268 } )
280269 // watching required with -r not implemented
281- it . skip ( 'It should add require with -r flag' , async ( ) => {
270+ it . skip ( 'should add require with -r flag' , async ( ) => {
282271 const ps = spawnTsNodeDev (
283272 [
284273 `-r ./add-req` ,
@@ -296,7 +285,7 @@ describe('ts-node-dev', function () {
296285 t . ok ( true )
297286 } )
298287
299- it ( 'It should handle --deps flag' , async ( ) => {
288+ it ( 'should handle --deps flag' , async ( ) => {
300289 const ps = spawnTsNodeDev ( [ `--deps` , `--respawn` , `req-package` ] . join ( ' ' ) )
301290
302291 await ps . waitForLine ( / P A C K A G E / )
@@ -316,7 +305,7 @@ describe('ts-node-dev', function () {
316305 t . ok ( true )
317306 } )
318307
319- it ( 'It should handle deep deps with --deps flag' , async ( ) => {
308+ it ( 'should handle deep deps with --deps flag' , async ( ) => {
320309 const ps = spawnTsNodeDev (
321310 [ `--all-deps` , `--respawn` , `req-package` ] . join ( ' ' )
322311 )
@@ -338,7 +327,7 @@ describe('ts-node-dev', function () {
338327 t . ok ( true )
339328 } )
340329
341- it . skip ( 'It error on wrong cli flag' , async ( ) => {
330+ it . skip ( 'should error on wrong cli flag' , async ( ) => {
342331 const ps = spawnTsNodeDev ( [ `--transpileOnly` , `req-package` ] . join ( ' ' ) )
343332
344333 await ps . waitForLine ( / b a d o p t i o n / )
0 commit comments