Skip to content

Commit 8c2d2b0

Browse files
zkochanclaude
andauthored
refactor: rewrite all tests to use native node:test (#223)
* refactor: rewrite all tests to use native node:test Replace tape, jest, and ts-jest with Node.js built-in test runner (node:test) and assertion module (node:assert) across all 28 packages. - tape-based tests → node --test with node:assert - jest-based tests → node --test with node:assert - TypeScript tests → node --experimental-strip-types --test - Removed tape, jest, ts-jest, @types/jest, @types/tape, ts-node devDeps Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address review comments - Remove unused beforeEach/mock imports in rename-overwrite test - Add assertion that group 2 tasks executed in run-groups test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3806401 commit 8c2d2b0

File tree

57 files changed

+449
-3192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+449
-3192
lines changed

better-path-resolve/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"index.js"
88
],
99
"scripts": {
10-
"test": "node test",
10+
"test": "node --test test.js",
1111
"md": "mos"
1212
},
1313
"engines": {
@@ -34,7 +34,6 @@
3434
},
3535
"devDependencies": {
3636
"mos": "2.0.0-alpha.3",
37-
"mos-plugin-readme": "^1.0.4",
38-
"tape": "^5.9.0"
37+
"mos-plugin-readme": "^1.0.4"
3938
}
4039
}

better-path-resolve/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict'
2-
const test = require('tape')
2+
const { test } = require('node:test')
3+
const assert = require('node:assert')
34
const betterPathResolve = require('.')
45

5-
test('betterPathResolve()', (t) => {
6-
t.equal(typeof betterPathResolve(), 'string')
7-
t.end()
6+
test('betterPathResolve()', () => {
7+
assert.strictEqual(typeof betterPathResolve(), 'string')
88
})

can-link/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"index.d.ts"
1010
],
1111
"scripts": {
12-
"test": "standard && node test",
12+
"test": "standard && node --test test.js",
1313
"md": "mos"
1414
},
1515
"repository": "https://github.com/zkochan/packages/tree/main/can-link",
@@ -32,8 +32,7 @@
3232
"can-link": "file:",
3333
"mos": "2.0.0-alpha.3",
3434
"mos-plugin-readme": "^1.0.4",
35-
"standard": "^16.0.4",
36-
"tape": "^5.9.0"
35+
"standard": "^16.0.4"
3736
},
3837
"mos": {
3938
"plugins": [

can-link/test.js

Lines changed: 33 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
2-
const test = require('tape')
2+
const { test } = require('node:test')
3+
const assert = require('node:assert')
34
const canLink = require('can-link')
45

56
const exdevErr = new Error('EXDEV: cross-device link not permitted')
@@ -11,88 +12,70 @@ eaccesErr.code = 'EACCES'
1112
const epermErr = new Error('EPERM: permission denied, link')
1213
epermErr.code = 'EPERM'
1314

14-
test('canLink.sync()', t => {
15-
t.ok(canLink.sync('package.json', 'node_modules/package.json'))
16-
t.notOk(canLink.sync('foo', 'bar', {
15+
test('canLink.sync()', () => {
16+
assert.ok(canLink.sync('package.json', 'node_modules/package.json'))
17+
assert.ok(!canLink.sync('foo', 'bar', {
1718
linkSync: () => { throw exdevErr },
1819
unlinkSync: () => {}
19-
}), 'cannot link on EXDEV error')
20-
t.notOk(canLink.sync('foo', 'bar', {
20+
}))
21+
assert.ok(!canLink.sync('foo', 'bar', {
2122
linkSync: () => { throw eaccesErr },
2223
unlinkSync: () => {}
23-
}), 'cannot link on EACCES error')
24-
t.notOk(canLink.sync('foo', 'bar', {
24+
}))
25+
assert.ok(!canLink.sync('foo', 'bar', {
2526
linkSync: () => { throw epermErr },
2627
unlinkSync: () => {}
27-
}), 'cannot link on EPERM error')
28-
t.throws(() => {
28+
}))
29+
assert.throws(() => {
2930
const fsMock = {
3031
linkSync: () => { throw new Error('Error') }
3132
}
3233
canLink.sync('foo', 'bar', fsMock)
33-
}, /Error/, 'errors are passed through if they are not EXDEV')
34-
t.end()
34+
}, /Error/)
3535
})
3636

37-
test('canLink() returns true', t => {
38-
canLink('package.json', 'node_modules/package.json')
39-
.then(can => {
40-
t.ok(can)
41-
t.end()
42-
})
43-
.catch(t.end)
37+
test('canLink() returns true', async () => {
38+
const can = await canLink('package.json', 'node_modules/package.json')
39+
assert.ok(can)
4440
})
4541

46-
test('canLink() returns false', t => {
47-
canLink('package.json', 'node_modules/package.json', {
42+
test('canLink() returns false', async () => {
43+
const can = await canLink('package.json', 'node_modules/package.json', {
4844
promises: {
4945
link: (existingPath, newPath, cb) => Promise.reject(exdevErr),
5046
unlink: (p, cb) => Promise.resolve()
5147
}
5248
})
53-
.then(can => {
54-
t.notOk(can)
55-
t.end()
56-
})
57-
.catch(t.end)
49+
assert.ok(!can)
5850
})
5951

60-
test('canLink() returns false on EACCES error', t => {
61-
canLink('package.json', 'node_modules/package.json', {
52+
test('canLink() returns false on EACCES error', async () => {
53+
const can = await canLink('package.json', 'node_modules/package.json', {
6254
promises: {
6355
link: (existingPath, newPath, cb) => Promise.reject(eaccesErr),
6456
unlink: (p, cb) => Promise.resolve()
6557
}
6658
})
67-
.then(can => {
68-
t.notOk(can)
69-
t.end()
70-
})
71-
.catch(t.end)
59+
assert.ok(!can)
7260
})
7361

74-
test('canLink() returns false on EPERM error', async t => {
62+
test('canLink() returns false on EPERM error', async () => {
7563
const can = await canLink('package.json', 'node_modules/package.json', {
7664
promises: {
7765
link: (existingPath, newPath, cb) => Promise.reject(epermErr),
78-
unlink: (p, cb) => cb()
66+
unlink: (p, cb) => Promise.resolve()
7967
}
8068
})
81-
t.notOk(can)
82-
t.end()
69+
assert.ok(!can)
8370
})
8471

85-
test('canLink() non-exdev error passed through', t => {
86-
canLink('package.json', 'node_modules/package.json', {
87-
promises: {
88-
link: (existingPath, newPath, cb) => Promise.reject(new Error('Error'))
89-
}
90-
})
91-
.then(can => {
92-
t.fail('should have failed')
93-
})
94-
.catch(err => {
95-
t.ok(err)
96-
t.end()
97-
})
72+
test('canLink() non-exdev error passed through', async () => {
73+
await assert.rejects(
74+
canLink('package.json', 'node_modules/package.json', {
75+
promises: {
76+
link: (existingPath, newPath, cb) => Promise.reject(new Error('Error'))
77+
}
78+
}),
79+
/Error/
80+
)
9881
})

can-write-to-dir/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"index.d.ts"
1010
],
1111
"scripts": {
12-
"test": "standard && node test"
12+
"test": "standard && node --test test.js"
1313
},
1414
"repository": "https://github.com/zkochan/packages/tree/main/can-write-to-dir",
1515
"keywords": [
@@ -34,7 +34,6 @@
3434
},
3535
"devDependencies": {
3636
"can-write-to-dir": "file:",
37-
"standard": "^16.0.4",
38-
"tape": "^5.9.0"
37+
"standard": "^16.0.4"
3938
}
4039
}

can-write-to-dir/test.js

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
2-
const test = require('tape')
2+
const { test } = require('node:test')
3+
const assert = require('node:assert')
34
const canWriteToDir = require('can-write-to-dir')
45

56
const eaccesErr = new Error('EACCES: permission denied, link')
@@ -8,59 +9,51 @@ eaccesErr.code = 'EACCES'
89
const epermErr = new Error('EPERM: permission denied, link')
910
epermErr.code = 'EPERM'
1011

11-
test('canWriteToDir.sync()', t => {
12-
t.ok(canWriteToDir.sync(process.cwd()))
13-
t.notOk(canWriteToDir.sync('/foo', {
12+
test('canWriteToDir.sync()', () => {
13+
assert.ok(canWriteToDir.sync(process.cwd()))
14+
assert.ok(!canWriteToDir.sync('/foo', {
1415
writeFileSync: () => { throw eaccesErr },
1516
unlinkSync: () => {}
16-
}), 'cannot link on EACCES error')
17-
t.notOk(canWriteToDir.sync('foo', {
17+
}))
18+
assert.ok(!canWriteToDir.sync('foo', {
1819
writeFileSync: () => { throw epermErr },
1920
unlinkSync: () => {}
20-
}), 'cannot link on EPERM error')
21-
t.throws(() => {
21+
}))
22+
assert.throws(() => {
2223
const fsMock = {
2324
linkSync: () => { throw new Error('Error') }
2425
}
2526
canWriteToDir.sync('foo', 'bar', fsMock)
26-
}, /Error/, 'errors are passed through if they are not EXDEV')
27-
t.end()
27+
}, /Error/)
2828
})
2929

30-
test('canWriteToDir() returns true', async t => {
31-
t.ok(await canWriteToDir(process.cwd()))
32-
t.end()
30+
test('canWriteToDir() returns true', async () => {
31+
assert.ok(await canWriteToDir(process.cwd()))
3332
})
3433

35-
test('canWriteToDir() returns false on EACCES error', async t => {
36-
t.notOk(await canWriteToDir('/', {
34+
test('canWriteToDir() returns false on EACCES error', async () => {
35+
assert.ok(!await canWriteToDir('/', {
3736
promises: {
3837
writeFile: (a1, a2, a3, cb) => Promise.reject(eaccesErr),
3938
unlink: (p, cb) => Promise.resolve()
4039
}
4140
}))
42-
t.end()
4341
})
4442

45-
test('canWriteToDir() returns false on EACCES error', async t => {
46-
t.notOk(await canWriteToDir('/', {
43+
test('canWriteToDir() returns false on EPERM error', async () => {
44+
assert.ok(!await canWriteToDir('/', {
4745
promises: {
4846
writeFile: (a1, a2, a3, cb) => Promise.reject(epermErr),
4947
unlink: (p, cb) => Promise.resolve()
5048
}
5149
}))
52-
t.end()
5350
})
5451

55-
test('canWriteToDir() non-exdev error passed through', async t => {
56-
let err
57-
try {
58-
await canWriteToDir('/', {
52+
test('canWriteToDir() non-exdev error passed through', async () => {
53+
await assert.rejects(
54+
canWriteToDir('/', {
5955
writeFile: (a1, a2, a3, cb) => cb(new Error('Error'))
60-
})
61-
} catch (_err) {
62-
err = _err
63-
}
64-
t.ok(err)
65-
t.end()
56+
}),
57+
/Error/
58+
)
6659
})

comver-to-semver/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"index.d.ts"
1010
],
1111
"scripts": {
12-
"test": "node test"
12+
"test": "node --test test.js"
1313
},
1414
"repository": "https://github.com/zkochan/packages/tree/main/comver-to-semver",
1515
"keywords": [
@@ -23,6 +23,5 @@
2323
"license": "MIT",
2424
"homepage": "https://github.com/zkochan/packages/tree/main/comver-to-semver#readme",
2525
"devDependencies": {
26-
"tape": "^5.9.0"
2726
}
2827
}

comver-to-semver/test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict'
2-
const test = require('tape')
2+
const { test } = require('node:test')
3+
const assert = require('node:assert')
34
const comverToSemver = require('.')
45

5-
test('canWriteToDir.sync()', t => {
6-
t.equal(comverToSemver('2'), '2.0.0')
7-
t.equal(comverToSemver('2.1'), '2.1.0')
8-
t.end()
6+
test('comverToSemver()', () => {
7+
assert.strictEqual(comverToSemver('2'), '2.0.0')
8+
assert.strictEqual(comverToSemver('2.1'), '2.1.0')
99
})

dir-is-case-sensitive/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lib"
1212
],
1313
"scripts": {
14-
"test": "ts-node test",
14+
"test": "node --experimental-strip-types --test test/index.ts",
1515
"tsc": "tsc",
1616
"prepublishOnly": "pnpm run tsc"
1717
},
@@ -36,10 +36,7 @@
3636
},
3737
"devDependencies": {
3838
"@types/node": "14.14.6",
39-
"@types/tape": "^4.13.4",
4039
"dir-is-case-sensitive": "file:",
41-
"tape": "^5.9.0",
42-
"ts-node": "^10.9.2",
4340
"typescript": "^4.9.5"
4441
}
4542
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
import { test } from 'node:test'
2+
import assert from 'node:assert'
13
import dirIsCaseSensitiveModule from 'dir-is-case-sensitive'
2-
import test from 'tape'
34

45
const dirIsCaseSensitive = dirIsCaseSensitiveModule.default ?? dirIsCaseSensitiveModule
56

6-
test('dirIsCaseSensitive()', async (t) => {
7+
test('dirIsCaseSensitive()', async () => {
78
const isCaseSensitive = await dirIsCaseSensitive(import.meta.dirname)
8-
t.equal(typeof isCaseSensitive, 'boolean')
9-
t.comment(isCaseSensitive ? 'directory is case sensitive' : 'directory is not case sensitive')
10-
t.end()
9+
assert.strictEqual(typeof isCaseSensitive, 'boolean')
1110
})

0 commit comments

Comments
 (0)