@@ -41,7 +41,7 @@ fs.removeSync(join(tmpDir, 'fixture'))
41
41
fs . copySync ( join ( __dirname , 'fixture' ) , scriptsDir )
42
42
describe ( 'ts-node-dev' , function ( ) {
43
43
this . timeout ( 5000 )
44
- it ( 'It should restart on file change' , async ( ) => {
44
+ it ( 'should restart on file change' , async ( ) => {
45
45
const ps = spawnTsNodeDev ( '--respawn --poll simple.ts' )
46
46
await ps . waitForLine ( / v 1 / )
47
47
setTimeout ( ( ) => replaceText ( 'dep.ts' , 'v1' , 'v2' ) , 250 )
@@ -52,7 +52,7 @@ describe('ts-node-dev', function () {
52
52
await replaceText ( 'dep.ts' , 'v2' , 'v1' )
53
53
} )
54
54
55
- it ( 'It allow watch arbitrary folder/file' , async ( ) => {
55
+ it ( 'allow watch arbitrary folder/file' , async ( ) => {
56
56
const ps = spawnTsNodeDev ( '--respawn --watch folder,folder2 simple.ts' )
57
57
await ps . waitForLine ( / v 1 / )
58
58
setTimeout ( ( ) => touch ( join ( scriptsDir , 'folder/some-file' ) ) , 250 )
@@ -61,7 +61,7 @@ describe('ts-node-dev', function () {
61
61
await ps . exit ( )
62
62
} )
63
63
64
- it ( 'It should report an error on start' , async ( ) => {
64
+ it ( 'should report an error on start' , async ( ) => {
65
65
const ps = spawnTsNodeDev ( '--respawn with-error.ts' )
66
66
await ps . waitForLine ( / [ E R R O R ] / )
67
67
const out = ps . getStdout ( )
@@ -80,7 +80,7 @@ describe('ts-node-dev', function () {
80
80
await replaceText ( 'with-error.ts' , '1' , `'1'` )
81
81
} )
82
82
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 ( ) => {
84
84
const ps = spawnTsNodeDev ( '--respawn --log-error with-error.ts' )
85
85
await ps . waitForErrorLine ( / e r r o r / )
86
86
@@ -96,9 +96,8 @@ describe('ts-node-dev', function () {
96
96
await replaceText ( 'with-error.ts' , '1' , `'1'` )
97
97
} )
98
98
99
- it ( 'It should restart on adding not imported module' , async ( ) => {
99
+ it ( 'should restart on adding not imported module' , async ( ) => {
100
100
const ps = spawnTsNodeDev ( '--respawn --error-recompile with-error.ts' , {
101
- // stdout: true,
102
101
env : {
103
102
TS_NODE_DEV_ERROR_RECOMPILE_TIMEOUT : 50 ,
104
103
} ,
@@ -113,13 +112,12 @@ describe('ts-node-dev', function () {
113
112
await replaceText ( 'dep-ts-error.ts' , 'string' , 'number' )
114
113
} )
115
114
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
+ `
121
120
const ps = spawnTsNodeDev ( '--respawn --error-recompile with-not-found.ts' , {
122
- //stdout: true,
123
121
env : {
124
122
TS_NODE_DEV_ERROR_RECOMPILE_TIMEOUT : 20 ,
125
123
} ,
@@ -134,12 +132,11 @@ describe('ts-node-dev', function () {
134
132
await removeFile ( 'not-found.ts' )
135
133
} )
136
134
137
- it ( 'It handles allowJs option and loads JS modules' , async ( ) => {
135
+ it ( 'should handle allowJs option and compile JS modules' , async ( ) => {
138
136
const cOptions = { allowJs : true , esModuleInterop : false }
139
137
const ps = spawnTsNodeDev (
140
138
[
141
139
`--respawn` ,
142
- `--compiler ttypescript` ,
143
140
`--compiler-options=${ JSON . stringify ( cOptions ) } ` ,
144
141
`js-module.js` ,
145
142
] . join ( ' ' )
@@ -149,7 +146,14 @@ describe('ts-node-dev', function () {
149
146
await ps . exit ( )
150
147
} )
151
148
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 ( ) => {
153
157
const cOptions = { resolveJsonModule : true }
154
158
const ps = spawnTsNodeDev (
155
159
[
@@ -164,43 +168,47 @@ describe('ts-node-dev', function () {
164
168
await ps . exit ( )
165
169
} )
166
170
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
+ } )
175
180
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
+ } )
182
189
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
+ } )
189
196
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
+ } )
201
209
} )
202
210
203
- it ( 'It allows to use TS Transformers ' , async ( ) => {
211
+ it ( 'should allow to use custom TS transformers ' , async ( ) => {
204
212
const cOptions = { plugins : [ { transform : 'ts-nameof' , type : 'raw' } ] }
205
213
const ps = spawnTsNodeDev (
206
214
[
@@ -230,38 +238,19 @@ describe('ts-node-dev', function () {
230
238
await ps . exit ( )
231
239
} )
232
240
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 ( ' ' ) )
255
244
await ps . waitForLine ( / P R E F E R D E P J S / )
256
245
await ps . waitForLine ( / P R E F E R T S / )
257
246
await ps . exit ( )
258
247
t . ok ( true )
259
248
} )
260
249
261
- it ( 'Use require all TS with --ts-prefer' , async ( ) => {
250
+ it ( 'should require TS modules with --ts-prefer-exts ' , async ( ) => {
262
251
const ps = spawnTsNodeDev (
263
252
[ `--respawn` , `--prefer-ts-exts` , `prefer/prefer` ] . join ( ' ' )
264
- ) //.turnOnOutput()
253
+ )
265
254
await ps . waitForLine ( / P R E F E R D E P T S / )
266
255
await ps . waitForLine ( / P R E F E R T S / )
267
256
@@ -278,7 +267,7 @@ describe('ts-node-dev', function () {
278
267
} )
279
268
} )
280
269
// 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 ( ) => {
282
271
const ps = spawnTsNodeDev (
283
272
[
284
273
`-r ./add-req` ,
@@ -296,7 +285,7 @@ describe('ts-node-dev', function () {
296
285
t . ok ( true )
297
286
} )
298
287
299
- it ( 'It should handle --deps flag' , async ( ) => {
288
+ it ( 'should handle --deps flag' , async ( ) => {
300
289
const ps = spawnTsNodeDev ( [ `--deps` , `--respawn` , `req-package` ] . join ( ' ' ) )
301
290
302
291
await ps . waitForLine ( / P A C K A G E / )
@@ -316,7 +305,7 @@ describe('ts-node-dev', function () {
316
305
t . ok ( true )
317
306
} )
318
307
319
- it ( 'It should handle deep deps with --deps flag' , async ( ) => {
308
+ it ( 'should handle deep deps with --deps flag' , async ( ) => {
320
309
const ps = spawnTsNodeDev (
321
310
[ `--all-deps` , `--respawn` , `req-package` ] . join ( ' ' )
322
311
)
@@ -338,7 +327,7 @@ describe('ts-node-dev', function () {
338
327
t . ok ( true )
339
328
} )
340
329
341
- it . skip ( 'It error on wrong cli flag' , async ( ) => {
330
+ it . skip ( 'should error on wrong cli flag' , async ( ) => {
342
331
const ps = spawnTsNodeDev ( [ `--transpileOnly` , `req-package` ] . join ( ' ' ) )
343
332
344
333
await ps . waitForLine ( / b a d o p t i o n / )
0 commit comments