Skip to content

Commit cd75fab

Browse files
committed
test: mjs
1 parent 8a0d92b commit cd75fab

5 files changed

Lines changed: 35 additions & 35 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
},
5353
"scripts": {
5454
"build": "rimraf lib && tsc -p tsconfig.lib.json",
55-
"test": "node test",
55+
"test": "node test/index.mjs",
5656
"lint": "eslint . --fix",
5757
"prepublishOnly": "npm run build",
5858
"prepare": "husky",

test/cli.mjs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { cli } from '../lib/cli.js'
55
tap.test('notify is enabled by default', t => {
66
const {
77
opts: { notify }
8-
} = cli(['node', 'lib/entrypoint.js', 'test'])
8+
} = cli(['node', 'lib/entrypoint.js', 'test/index.mjs'])
99

1010
t.equal(notify, true)
1111
t.end()
@@ -14,7 +14,7 @@ tap.test('notify is enabled by default', t => {
1414
tap.test('--no-notify', t => {
1515
const {
1616
opts: { notify }
17-
} = cli(['node', 'lib/entrypoint.js', '--no-notify', 'test'])
17+
} = cli(['node', 'lib/entrypoint.js', '--no-notify', 'test/index.mjs'])
1818

1919
t.equal(notify, false)
2020
t.end()
@@ -23,7 +23,7 @@ tap.test('--no-notify', t => {
2323
tap.test('--notify=false', t => {
2424
const {
2525
opts: { notify }
26-
} = cli(['node', 'lib/entrypoint.js', '--notify=false', 'test'])
26+
} = cli(['node', 'lib/entrypoint.js', '--notify=false', 'test/index.mjs'])
2727

2828
t.equal(notify, false)
2929
t.end()
@@ -32,7 +32,7 @@ tap.test('--notify=false', t => {
3232
tap.test('--notify', t => {
3333
const {
3434
opts: { notify }
35-
} = cli(['node', 'lib/entrypoint.js', '--notify', 'test'])
35+
} = cli(['node', 'lib/entrypoint.js', '--notify', 'test/index.mjs'])
3636

3737
t.equal(notify, true)
3838
t.end()
@@ -41,7 +41,7 @@ tap.test('--notify', t => {
4141
tap.test('--notify=true', t => {
4242
const {
4343
opts: { notify }
44-
} = cli(['node', 'lib/entrypoint.js', '--notify=true', 'test'])
44+
} = cli(['node', 'lib/entrypoint.js', '--notify=true', 'test/index.mjs'])
4545

4646
t.equal(notify, true)
4747
t.end()
@@ -87,7 +87,7 @@ tap.test('--expose_gc gc.js foo', t => {
8787
})
8888

8989
tap.test('--preserve-symlinks test', t => {
90-
const argv = 'node lib/entrypoint.js --preserve-symlinks test'.split(' ')
90+
const argv = 'node lib/entrypoint.js --preserve-symlinks test/index.mjs'.split(' ')
9191
const { nodeArgs } = cli(argv)
9292
t.same(nodeArgs, ['--preserve-symlinks'])
9393
t.end()
@@ -96,7 +96,7 @@ tap.test('--preserve-symlinks test', t => {
9696
tap.test('clear is not enabled by default', t => {
9797
const {
9898
opts: { clear }
99-
} = cli(['node', 'lib/entrypoint.js', 'test'])
99+
} = cli(['node', 'lib/entrypoint.js', 'test/index.mjs'])
100100

101101
t.notOk(clear)
102102
t.end()
@@ -105,7 +105,7 @@ tap.test('clear is not enabled by default', t => {
105105
tap.test('--clear enables clear', t => {
106106
const {
107107
opts: { clear }
108-
} = cli(['node', 'lib/entrypoint.js', '--clear', 'test'])
108+
} = cli(['node', 'lib/entrypoint.js', '--clear', 'test/index.mjs'])
109109

110110
t.ok(clear)
111111
t.end()
@@ -114,7 +114,7 @@ tap.test('--clear enables clear', t => {
114114
tap.test('interval default', t => {
115115
const {
116116
opts: { interval }
117-
} = cli(['node', 'lib/entrypoint.js', 'test'])
117+
} = cli(['node', 'lib/entrypoint.js', 'test/index.mjs'])
118118

119119
t.equal(interval, 1000)
120120
t.end()
@@ -123,7 +123,7 @@ tap.test('interval default', t => {
123123
tap.test('--interval=2000', t => {
124124
const {
125125
opts: { interval }
126-
} = cli(['node', 'lib/entrypoint.js', '--interval=2000', 'test'])
126+
} = cli(['node', 'lib/entrypoint.js', '--interval=2000', 'test/index.mjs'])
127127

128128
t.equal(interval, 2000)
129129
t.end()
@@ -132,7 +132,7 @@ tap.test('--interval=2000', t => {
132132
tap.test('debounce default', t => {
133133
const {
134134
opts: { debounce }
135-
} = cli(['node', 'lib/entrypoint.js', 'test'])
135+
} = cli(['node', 'lib/entrypoint.js', 'test/index.mjs'])
136136

137137
t.equal(debounce, 10)
138138
t.end()
@@ -141,7 +141,7 @@ tap.test('debounce default', t => {
141141
tap.test('--debounce=2000', t => {
142142
const {
143143
opts: { debounce }
144-
} = cli(['node', 'lib/entrypoint.js', '--debounce=2000', 'test'])
144+
} = cli(['node', 'lib/entrypoint.js', '--debounce=2000', 'test/index.mjs'])
145145

146146
t.equal(debounce, 2000)
147147
t.end()
@@ -153,7 +153,7 @@ tap.test('--require source-map-support/register', t => {
153153
'lib/entrypoint.js',
154154
'--require',
155155
'source-map-support/register',
156-
'test'
156+
'test/index.mjs'
157157
])
158158

159159
t.same(nodeArgs, ['--require=source-map-support/register'])
@@ -165,43 +165,43 @@ tap.test('--require=source-map-support/register', t => {
165165
'node',
166166
'lib/entrypoint.js',
167167
'--require=source-map-support/register',
168-
'test'
168+
'test/index.mjs'
169169
])
170170

171171
t.same(nodeArgs, ['--require=source-map-support/register'])
172172
t.end()
173173
})
174174

175175
tap.test('-r source-map-support/register', t => {
176-
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-r', 'source-map-support/register', 'test'])
176+
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-r', 'source-map-support/register', 'test/index.mjs'])
177177

178178
t.same(nodeArgs, ['--require=source-map-support/register'])
179179
t.end()
180180
})
181181

182182
tap.test('-r=source-map-support/register', t => {
183-
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-r=source-map-support/register', 'test'])
183+
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-r=source-map-support/register', 'test/index.mjs'])
184184

185185
t.same(nodeArgs, ['--require=source-map-support/register'])
186186
t.end()
187187
})
188188

189189
tap.test('--inspect=127.0.0.1:12345', t => {
190-
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '--inspect=127.0.0.1:12345', 'test'])
190+
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '--inspect=127.0.0.1:12345', 'test/index.mjs'])
191191

192192
t.same(nodeArgs, ['--inspect=127.0.0.1:12345'])
193193
t.end()
194194
})
195195

196196
tap.test('--inspect', t => {
197-
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '--inspect', 'test'])
197+
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '--inspect', 'test/index.mjs'])
198198

199199
t.same(nodeArgs, ['--inspect'])
200200
t.end()
201201
})
202202

203203
tap.test('--no-warnings', t => {
204-
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '--no-warnings', 'test'])
204+
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '--no-warnings', 'test/index.mjs'])
205205

206206
t.same(nodeArgs, ['--no-warnings'])
207207
t.end()
@@ -215,7 +215,7 @@ tap.test('--require source-map-support/register --require ts-node-maintained/reg
215215
'source-map-support/register',
216216
'--require',
217217
'ts-node-maintained/register',
218-
'test'
218+
'test/index.mjs'
219219
])
220220

221221
t.same(nodeArgs, ['--require=source-map-support/register', '--require=ts-node-maintained/register'])
@@ -244,55 +244,55 @@ tap.test('An unknown argument with a value instead of a script should fail.', t
244244
})
245245

246246
tap.test('An unknown argument with a value', t => {
247-
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '--unknown-arg=value', 'test'])
247+
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '--unknown-arg=value', 'test/index.mjs'])
248248

249249
t.same(nodeArgs, ['--unknown-arg=value'])
250250
t.end()
251251
})
252252

253253
tap.test('An unknown argument without a value can use -- to delimit', t => {
254254
// use -- to delimit the end of options
255-
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '--unknown-arg', '--', 'test'])
255+
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '--unknown-arg', '--', 'test/index.mjs'])
256256

257257
t.same(nodeArgs, ['--unknown-arg'])
258258
t.end()
259259
})
260260

261261
tap.test('Single dash with value', t => {
262-
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-u', 'value', 'test'])
262+
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-u', 'value', 'test/index.mjs'])
263263

264264
t.same(nodeArgs, ['-u=value'])
265265
t.end()
266266
})
267267

268268
tap.test('Single dash with = and value', t => {
269-
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-u=value', 'test'])
269+
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-u=value', 'test/index.mjs'])
270270

271271
t.same(nodeArgs, ['-u=value'])
272272
t.end()
273273
})
274274

275275
tap.test('Single dash without value should fail', t => {
276-
t.throws(() => cli(['node', 'lib/entrypoint.js', '-u', 'test']))
276+
t.throws(() => cli(['node', 'lib/entrypoint.js', '-u', 'test/index.mjs']))
277277
t.end()
278278
})
279279

280280
tap.test('Single dash without value can use -- to delimit', t => {
281-
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-u', '--', 'test'])
281+
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-u', '--', 'test/index.mjs'])
282282

283283
t.same(nodeArgs, ['-u'])
284284
t.end()
285285
})
286286

287287
tap.test('Repeated single dash', t => {
288-
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-u=value1', '-u=value2', 'test'])
288+
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-u=value1', '-u=value2', 'test/index.mjs'])
289289

290290
t.same(nodeArgs, ['-u=value1', '-u=value2'])
291291
t.end()
292292
})
293293

294294
tap.test('Repeated single dash without =', t => {
295-
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-u', 'value1', '-u', 'value2', 'test'])
295+
const { nodeArgs } = cli(['node', 'lib/entrypoint.js', '-u', 'value1', '-u', 'value2', 'test/index.mjs'])
296296

297297
t.same(nodeArgs, ['-u=value1', '-u=value2'])
298298
t.end()
@@ -304,7 +304,7 @@ tap.test(
304304
// Everything except clear gets passed to node.
305305
// Don't forget to use -- to delimit!
306306
const argv =
307-
'node lib/entrypoint.js --all --command-line --arguments --clear --that --are --not --node-dev --options -- test'.split(
307+
'node lib/entrypoint.js --all --command-line --arguments --clear --that --are --not --node-dev --options -- test/index.mjs'.split(
308308
' '
309309
)
310310
const { nodeArgs } = cli(argv)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// We should not be able to load typescript files as ESModules
2-
export default ['test', 'data'] as const
2+
export default ['test/index.mjs', 'data'] as const

test/index.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/index.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import './cli.mjs'
2+
import './log.mjs'
3+
import './run.js'
4+
import './spawn/index.js'

0 commit comments

Comments
 (0)