Skip to content

Commit f4ac350

Browse files
committed
Use Node test runner
1 parent f6bd64e commit f4ac350

6 files changed

Lines changed: 178 additions & 211 deletions

File tree

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"devDependencies": {
2020
"@types/mdast": "^3.0.0",
21-
"@types/tape": "^4.0.0",
21+
"@types/node": "^20.0.0",
2222
"c8": "^7.0.0",
2323
"camelcase": "^7.0.0",
2424
"execa": "^7.0.0",
@@ -28,7 +28,6 @@
2828
"prettier": "^2.0.0",
2929
"remark-preset-wooorm": "^9.0.0",
3030
"rimraf": "^3.0.0",
31-
"tape": "^5.0.0",
3231
"type-coverage": "^2.0.0",
3332
"typescript": "^5.0.0",
3433
"unified": "^10.0.0",

packages/remark-cli/test.js

Lines changed: 64 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,77 @@
1-
import {URL, fileURLToPath} from 'node:url'
1+
import assert from 'node:assert/strict'
2+
import {fileURLToPath} from 'node:url'
3+
import test from 'node:test'
24
import {execa} from 'execa'
3-
import test from 'tape'
45

5-
test('remark-cli', (t) => {
6-
t.plan(2)
7-
8-
t.test('should show help on `--help`', (t) => {
6+
test('remark-cli', async (t) => {
7+
await t.test('should show help on `--help`', async () => {
98
const bin = fileURLToPath(new URL('cli.js', import.meta.url))
109

11-
t.plan(1)
10+
const result = await execa(bin, ['--help'])
1211

13-
execa(bin, ['--help']).then((result) => {
14-
t.equal(
15-
result.stdout,
16-
[
17-
'Usage: remark [options] [path | glob ...]',
18-
'',
19-
' Command line interface to inspect and change markdown files with remark',
20-
'',
21-
'Options:',
22-
'',
23-
' -h --help output usage information',
24-
' -v --version output version number',
25-
' -o --output [path] specify output location',
26-
' -r --rc-path <path> specify configuration file',
27-
' -i --ignore-path <path> specify ignore file',
28-
' -s --setting <settings> specify settings',
29-
' -e --ext <extensions> specify extensions',
30-
' -u --use <plugins> use plugins',
31-
' -w --watch watch for changes and reprocess',
32-
' -q --quiet output only warnings and errors',
33-
' -S --silent output only errors',
34-
' -f --frail exit with 1 on warnings',
35-
' -t --tree specify input and output as syntax tree',
36-
' --report <reporter> specify reporter',
37-
' --file-path <path> specify path to process as',
38-
' --ignore-path-resolve-from dir|cwd resolve patterns in `ignore-path` from its directory or cwd',
39-
' --ignore-pattern <globs> specify ignore patterns',
40-
' --silently-ignore do not fail when given ignored files',
41-
' --tree-in specify input as syntax tree',
42-
' --tree-out output syntax tree',
43-
' --inspect output formatted syntax tree',
44-
' --[no-]stdout specify writing to stdout (on by default)',
45-
' --[no-]color specify color in report (on by default)',
46-
' --[no-]config search for configuration files (on by default)',
47-
' --[no-]ignore search for ignore files (on by default)',
48-
'',
49-
'Examples:',
50-
'',
51-
' # Process `input.md`',
52-
' $ remark input.md -o output.md',
53-
'',
54-
' # Pipe',
55-
' $ remark < input.md > output.md',
56-
'',
57-
' # Rewrite all applicable files',
58-
' $ remark . -o'
59-
].join('\n'),
60-
'should show help'
61-
)
62-
})
12+
assert.equal(
13+
result.stdout,
14+
[
15+
'Usage: remark [options] [path | glob ...]',
16+
'',
17+
' Command line interface to inspect and change markdown files with remark',
18+
'',
19+
'Options:',
20+
'',
21+
' -h --help output usage information',
22+
' -v --version output version number',
23+
' -o --output [path] specify output location',
24+
' -r --rc-path <path> specify configuration file',
25+
' -i --ignore-path <path> specify ignore file',
26+
' -s --setting <settings> specify settings',
27+
' -e --ext <extensions> specify extensions',
28+
' -u --use <plugins> use plugins',
29+
' -w --watch watch for changes and reprocess',
30+
' -q --quiet output only warnings and errors',
31+
' -S --silent output only errors',
32+
' -f --frail exit with 1 on warnings',
33+
' -t --tree specify input and output as syntax tree',
34+
' --report <reporter> specify reporter',
35+
' --file-path <path> specify path to process as',
36+
' --ignore-path-resolve-from dir|cwd resolve patterns in `ignore-path` from its directory or cwd',
37+
' --ignore-pattern <globs> specify ignore patterns',
38+
' --silently-ignore do not fail when given ignored files',
39+
' --tree-in specify input as syntax tree',
40+
' --tree-out output syntax tree',
41+
' --inspect output formatted syntax tree',
42+
' --[no-]stdout specify writing to stdout (on by default)',
43+
' --[no-]color specify color in report (on by default)',
44+
' --[no-]config search for configuration files (on by default)',
45+
' --[no-]ignore search for ignore files (on by default)',
46+
'',
47+
'Examples:',
48+
'',
49+
' # Process `input.md`',
50+
' $ remark input.md -o output.md',
51+
'',
52+
' # Pipe',
53+
' $ remark < input.md > output.md',
54+
'',
55+
' # Rewrite all applicable files',
56+
' $ remark . -o'
57+
].join('\n'),
58+
'should show help'
59+
)
6360
})
6461

65-
t.test('should show version on `--version`', (t) => {
62+
await t.test('should show version on `--version`', async () => {
6663
const bin = fileURLToPath(new URL('cli.js', import.meta.url))
6764

68-
t.plan(2)
65+
const result = await execa(bin, ['--version'])
6966

70-
execa(bin, ['--version']).then((result) => {
71-
t.ok(
72-
/remark: \d+\.\d+\.\d+/.test(result.stdout),
73-
'should include remark version'
74-
)
67+
assert.ok(
68+
/remark: \d+\.\d+\.\d+/.test(result.stdout),
69+
'should include remark version'
70+
)
7571

76-
t.ok(
77-
/remark-cli: \d+\.\d+\.\d+/.test(result.stdout),
78-
'should include remark-cli version'
79-
)
80-
})
72+
assert.ok(
73+
/remark-cli: \d+\.\d+\.\d+/.test(result.stdout),
74+
'should include remark-cli version'
75+
)
8176
})
8277
})

packages/remark-parse/test.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import test from 'tape'
1+
import assert from 'node:assert/strict'
2+
import test from 'node:test'
23
import {unified} from 'unified'
34
import {gfm} from 'micromark-extension-gfm'
45
import {gfmFromMarkdown} from 'mdast-util-gfm'
56
import {removePosition} from 'unist-util-remove-position'
67
import remarkParse from './index.js'
78

8-
test('remarkParse', (t) => {
9-
t.equal(
9+
test('remarkParse', async (t) => {
10+
assert.equal(
1011
unified().use(remarkParse).parse('Alfred').children.length,
1112
1,
1213
'should accept a `string`'
1314
)
1415

15-
t.test('extensions', (t) => {
16+
await t.test('extensions', () => {
1617
const tree = unified()
1718
.data('micromarkExtensions', [gfm()])
1819
.data('fromMarkdownExtensions', [gfmFromMarkdown()])
@@ -21,7 +22,7 @@ test('remarkParse', (t) => {
2122

2223
removePosition(tree, true)
2324

24-
t.deepEqual(
25+
assert.deepEqual(
2526
tree,
2627
{
2728
type: 'root',
@@ -61,9 +62,5 @@ test('remarkParse', (t) => {
6162
},
6263
'should work'
6364
)
64-
65-
t.end()
6665
})
67-
68-
t.end()
6966
})

0 commit comments

Comments
 (0)