Skip to content

Commit 922b40a

Browse files
committedFeb 4, 2023
Use Node test runner
1 parent 446e58b commit 922b40a

File tree

3 files changed

+41
-42
lines changed

3 files changed

+41
-42
lines changed
 

‎.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ jobs:
2020
- ubuntu-latest
2121
- windows-latest
2222
node:
23-
- lts/fermium
23+
- lts/gallium
2424
- node

‎package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,13 @@
5353
"vfile-statistics": "^2.0.0"
5454
},
5555
"devDependencies": {
56-
"@types/tape": "^4.0.0",
56+
"@types/node": "^18.0.0",
5757
"c8": "^7.0.0",
5858
"cross-env": "^7.0.0",
5959
"prettier": "^2.0.0",
6060
"remark-cli": "^11.0.0",
6161
"remark-preset-wooorm": "^9.0.0",
6262
"strip-ansi": "^7.0.0",
63-
"tape": "^5.0.0",
6463
"type-coverage": "^2.0.0",
6564
"typescript": "^4.0.0",
6665
"xo": "^0.53.0"

‎test.js

+39-39
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import assert from 'node:assert/strict'
12
import path from 'node:path'
23
import process from 'node:process'
3-
import test from 'tape'
4+
import test from 'node:test'
45
import strip from 'strip-ansi'
56
import {VFile} from 'vfile'
67
import reporterDefault, {reporter} from './index.js'
@@ -50,47 +51,44 @@ try {
5051
}
5152
/* eslint-enable no-undef */
5253

53-
test('vfile-reporter', (t) => {
54-
t.equal(
54+
test('vfile-reporter', () => {
55+
assert.equal(
5556
reporter,
5657
reporterDefault,
5758
'should expose `reporter` as a named and a default export'
5859
)
5960

60-
/** @type {VFile} */
61-
let file
61+
assert.equal(reporter(), '', 'should return empty without a file')
6262

63-
t.equal(reporter(), '', 'should return empty without a file')
63+
assert.equal(reporter([]), '', 'should return empty when not given files')
6464

65-
t.equal(reporter([]), '', 'should return empty when not given files')
65+
assert.equal(reporter(exception), exception.stack, 'should support an error')
6666

67-
t.equal(reporter(exception), exception.stack, 'should support an error')
68-
69-
file = new VFile({path: 'a.js'})
67+
let file = new VFile({path: 'a.js'})
7068

7169
try {
7270
file.fail('Error!')
7371
} catch {}
7472

75-
t.equal(
73+
assert.equal(
7674
reporter(file.messages[0]),
7775
'a.js:1:1: Error!',
7876
'should support a fatal message'
7977
)
8078

81-
t.equal(
79+
assert.equal(
8280
strip(reporter(new VFile({path: 'a.js'}))),
8381
'a.js: no issues found',
8482
'should work on a single file'
8583
)
8684

87-
t.equal(
85+
assert.equal(
8886
strip(reporter(new VFile())),
8987
'no issues found',
9088
'should work without file-paths'
9189
)
9290

93-
t.equal(
91+
assert.equal(
9492
strip(reporter([new VFile({path: 'a.js'}), new VFile({path: 'b.js'})])),
9593
'a.js: no issues found\nb.js: no issues found',
9694
'should work on files without messages'
@@ -99,7 +97,7 @@ test('vfile-reporter', (t) => {
9997
file = new VFile({path: 'a.js'})
10098
file.message('Warning!')
10199

102-
t.equal(
100+
assert.equal(
103101
strip(reporter([file, new VFile({path: 'b.js'})])),
104102
[
105103
'a.js',
@@ -118,7 +116,7 @@ test('vfile-reporter', (t) => {
118116
file.fail('Error!')
119117
} catch {}
120118

121-
t.equal(
119+
assert.equal(
122120
strip(reporter([file, new VFile({path: 'b.js'})])),
123121
[
124122
'a.js',
@@ -146,7 +144,7 @@ test('vfile-reporter', (t) => {
146144
file.fail('Another error!')
147145
} catch {}
148146

149-
t.equal(
147+
assert.equal(
150148
strip(reporter(file)),
151149
[
152150
'a.js',
@@ -166,7 +164,7 @@ test('vfile-reporter', (t) => {
166164
'should work on files with multiple mixed messages'
167165
)
168166

169-
t.equal(
167+
assert.equal(
170168
reporter(file, {color: false}),
171169
[
172170
'a.js',
@@ -189,7 +187,7 @@ test('vfile-reporter', (t) => {
189187
file = new VFile()
190188
Object.assign(file.message('Warning!'), {position: null})
191189

192-
t.equal(
190+
assert.equal(
193191
strip(reporter(file)),
194192
' warning Warning!\n\n' + chars.warning + ' 1 warning',
195193
'should support a missing position'
@@ -198,7 +196,7 @@ test('vfile-reporter', (t) => {
198196
file = new VFile()
199197
file.message('Warning!', {line: 3, column: 2})
200198

201-
t.equal(
199+
assert.equal(
202200
strip(reporter(file)),
203201
[' 3:2 warning Warning!', '', chars.warning + ' 1 warning'].join('\n'),
204202
'should support a single point'
@@ -210,7 +208,7 @@ test('vfile-reporter', (t) => {
210208
end: {line: 4, column: 8}
211209
})
212210

213-
t.equal(
211+
assert.equal(
214212
strip(reporter(file)),
215213
[' 3:2-4:8 warning Warning!', '', chars.warning + ' 1 warning'].join(
216214
'\n'
@@ -225,7 +223,7 @@ test('vfile-reporter', (t) => {
225223
})
226224
file.basename = 'foo.bar'
227225

228-
t.equal(
226+
assert.equal(
229227
strip(reporter(file)),
230228
[
231229
'foo.bar',
@@ -242,7 +240,7 @@ test('vfile-reporter', (t) => {
242240
file.fail(exception)
243241
} catch {}
244242

245-
t.equal(
243+
assert.equal(
246244
cleanStack(strip(reporter(file)), 3),
247245
[
248246
'test.js',
@@ -258,7 +256,7 @@ test('vfile-reporter', (t) => {
258256
file.fail(exception, undefined, 'foo:bar')
259257
} catch {}
260258

261-
t.equal(
259+
assert.equal(
262260
cleanStack(strip(reporter(file)), 3),
263261
[
264262
'test.js',
@@ -274,7 +272,7 @@ test('vfile-reporter', (t) => {
274272
file.fail(changedMessage)
275273
} catch {}
276274

277-
t.equal(
275+
assert.equal(
278276
cleanStack(strip(reporter(file)), 3),
279277
'test.js\n 1:1 error ReferenceError: foo\n at test.js:1:1',
280278
'should support a “real” error with a changed message'
@@ -286,7 +284,7 @@ test('vfile-reporter', (t) => {
286284
file.fail(multilineException)
287285
} catch {}
288286

289-
t.equal(
287+
assert.equal(
290288
cleanStack(strip(reporter(file)), 5),
291289
[
292290
'test.js',
@@ -304,7 +302,7 @@ test('vfile-reporter', (t) => {
304302
file.fail(multilineException, undefined, 'alpha:bravo')
305303
} catch {}
306304

307-
t.equal(
305+
assert.equal(
308306
cleanStack(strip(reporter(file)), 5),
309307
[
310308
'test.js',
@@ -321,7 +319,7 @@ test('vfile-reporter', (t) => {
321319
warning.note = 'Lorem ipsum dolor sit amet.'
322320
file.message('...and some more warnings')
323321

324-
t.equal(
322+
assert.equal(
325323
strip(reporter(file, {verbose: true})),
326324
[
327325
'a.js',
@@ -337,7 +335,7 @@ test('vfile-reporter', (t) => {
337335
file = new VFile({path: 'a.js'})
338336
file.message('Warning!')
339337

340-
t.equal(
338+
assert.equal(
341339
strip(reporter([file, new VFile({path: 'b.js'})], {quiet: true})),
342340
['a.js', ' 1:1 warning Warning!', '', chars.warning + ' 1 warning'].join(
343341
'\n'
@@ -354,7 +352,7 @@ test('vfile-reporter', (t) => {
354352

355353
fileB.message('Warning!')
356354

357-
t.equal(
355+
assert.equal(
358356
strip(reporter([file, fileB], {silent: true})),
359357
['a.js', ' 1:1 error Error!', '', chars.error + ' 1 error'].join('\n'),
360358
'should ignore non-failures in `silent` mode'
@@ -363,7 +361,7 @@ test('vfile-reporter', (t) => {
363361
file = new VFile({path: 'a.js'})
364362
file.stem = 'b'
365363

366-
t.equal(
364+
assert.equal(
367365
strip(reporter(file)),
368366
'a.js: no issues found',
369367
'should support `history`'
@@ -372,9 +370,13 @@ test('vfile-reporter', (t) => {
372370
file = new VFile({path: 'a.js'})
373371
file.stored = true
374372

375-
t.equal(strip(reporter(file)), 'a.js: written', 'should support `stored`')
373+
assert.equal(
374+
strip(reporter(file)),
375+
'a.js: written',
376+
'should support `stored`'
377+
)
376378

377-
t.equal(
379+
assert.equal(
378380
reporter(file, {color: false}),
379381
'a.js: written',
380382
'should support `stored` (w/o color)'
@@ -384,29 +386,27 @@ test('vfile-reporter', (t) => {
384386
file.stem = 'b'
385387
file.stored = true
386388

387-
t.equal(
389+
assert.equal(
388390
strip(reporter(file)),
389391
'a.js > b.js: written',
390392
'should expose the stored file-path'
391393
)
392394

393-
t.equal(
395+
assert.equal(
394396
reporter(new VFile({path: 'a.js'}), {color: true}),
395397
'\u001B[4m\u001B[32ma.js\u001B[39m\u001B[24m: no issues found',
396398
'should support `color: true`'
397399
)
398400

399-
t.equal(
401+
assert.equal(
400402
reporter(new VFile({path: 'a.js'}), {color: false}),
401403
'a.js: no issues found',
402404
'should support `color: false`'
403405
)
404-
405-
t.end()
406406
})
407407

408408
/**
409-
* @param {string|undefined} stack
409+
* @param {string | undefined} stack
410410
* @param {number} max
411411
*/
412412
function cleanStack(stack, max) {

0 commit comments

Comments
 (0)
Please sign in to comment.