Skip to content

Commit 2358aa2

Browse files
owlstronautwraithgar
authored andcommitted
chore: swap from tap to built-in node:test
1 parent 23a9e2c commit 2358aa2

9 files changed

Lines changed: 79 additions & 66 deletions

File tree

.github/workflows/audit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ jobs:
3030
uses: actions/setup-node@v4
3131
id: node
3232
with:
33-
node-version: 22.x
34-
check-latest: contains('22.x', '.x')
33+
node-version: 24.x
34+
check-latest: contains('24.x', '.x')
3535
- name: Install Latest npm
3636
uses: ./.github/actions/install-latest-npm
3737
with:

.github/workflows/ci-release.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ jobs:
5151
uses: actions/setup-node@v4
5252
id: node
5353
with:
54-
node-version: 22.x
55-
check-latest: contains('22.x', '.x')
54+
node-version: 24.x
55+
check-latest: contains('24.x', '.x')
5656
- name: Install Latest npm
5757
uses: ./.github/actions/install-latest-npm
5858
with:
@@ -95,6 +95,7 @@ jobs:
9595
- 20.x
9696
- 22.9.0
9797
- 22.x
98+
- 24.x
9899
exclude:
99100
- platform: { name: macOS, os: macos-13, shell: bash }
100101
node-version: 20.17.0
@@ -104,6 +105,8 @@ jobs:
104105
node-version: 22.9.0
105106
- platform: { name: macOS, os: macos-13, shell: bash }
106107
node-version: 22.x
108+
- platform: { name: macOS, os: macos-13, shell: bash }
109+
node-version: 24.x
107110
runs-on: ${{ matrix.platform.os }}
108111
defaults:
109112
run:
@@ -137,9 +140,14 @@ jobs:
137140
node: ${{ steps.node.outputs.node-version }}
138141
- name: Install Dependencies
139142
run: npm i --ignore-scripts --no-audit --no-fund
140-
- name: Add Problem Matcher
141-
run: echo "::add-matcher::.github/matchers/tap.json"
143+
- name: Test (with coverage on Node >= 24)
144+
if: ${{ startsWith(matrix.node-version, '24') }}
145+
run: npm run test:cover --ignore-scripts
146+
- name: Test (on Node 20 with globbing workaround)
147+
if: ${{ startsWith(matrix.node-version, '20') }}
148+
run: npm run test:node20 --ignore-scripts
142149
- name: Test
150+
if: ${{ !startsWith(matrix.node-version, '24') && !startsWith(matrix.node-version, '20') }}
143151
run: npm test --ignore-scripts
144152
- name: Conclude Check
145153
uses: LouisBrunner/checks-action@v1.6.0

.github/workflows/ci.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
uses: actions/setup-node@v4
3535
id: node
3636
with:
37-
node-version: 22.x
38-
check-latest: contains('22.x', '.x')
37+
node-version: 24.x
38+
check-latest: contains('24.x', '.x')
3939
- name: Install Latest npm
4040
uses: ./.github/actions/install-latest-npm
4141
with:
@@ -71,6 +71,7 @@ jobs:
7171
- 20.x
7272
- 22.9.0
7373
- 22.x
74+
- 24.x
7475
exclude:
7576
- platform: { name: macOS, os: macos-13, shell: bash }
7677
node-version: 20.17.0
@@ -80,6 +81,8 @@ jobs:
8081
node-version: 22.9.0
8182
- platform: { name: macOS, os: macos-13, shell: bash }
8283
node-version: 22.x
84+
- platform: { name: macOS, os: macos-13, shell: bash }
85+
node-version: 24.x
8386
runs-on: ${{ matrix.platform.os }}
8487
defaults:
8588
run:
@@ -103,7 +106,12 @@ jobs:
103106
node: ${{ steps.node.outputs.node-version }}
104107
- name: Install Dependencies
105108
run: npm i --ignore-scripts --no-audit --no-fund
106-
- name: Add Problem Matcher
107-
run: echo "::add-matcher::.github/matchers/tap.json"
109+
- name: Test (with coverage on Node >= 24)
110+
if: ${{ startsWith(matrix.node-version, '24') }}
111+
run: npm run test:cover --ignore-scripts
112+
- name: Test (on Node 20 with globbing workaround)
113+
if: ${{ startsWith(matrix.node-version, '20') }}
114+
run: npm run test:node20 --ignore-scripts
108115
- name: Test
116+
if: ${{ !startsWith(matrix.node-version, '24') && !startsWith(matrix.node-version, '20') }}
109117
run: npm test --ignore-scripts

.github/workflows/post-dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828
uses: actions/setup-node@v4
2929
id: node
3030
with:
31-
node-version: 22.x
32-
check-latest: contains('22.x', '.x')
31+
node-version: 24.x
32+
check-latest: contains('24.x', '.x')
3333
- name: Install Latest npm
3434
uses: ./.github/actions/install-latest-npm
3535
with:

.github/workflows/pull-request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
uses: actions/setup-node@v4
3535
id: node
3636
with:
37-
node-version: 22.x
38-
check-latest: contains('22.x', '.x')
37+
node-version: 24.x
38+
check-latest: contains('24.x', '.x')
3939
- name: Install Latest npm
4040
uses: ./.github/actions/install-latest-npm
4141
with:

.github/workflows/release-integration.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545
uses: actions/setup-node@v4
4646
id: node
4747
with:
48-
node-version: 22.x
49-
check-latest: contains('22.x', '.x')
48+
node-version: 24.x
49+
check-latest: contains('24.x', '.x')
5050
- name: Install Latest npm
5151
uses: ./.github/actions/install-latest-npm
5252
with:

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ jobs:
3939
uses: actions/setup-node@v4
4040
id: node
4141
with:
42-
node-version: 22.x
43-
check-latest: contains('22.x', '.x')
42+
node-version: 24.x
43+
check-latest: contains('24.x', '.x')
4444
- name: Install Latest npm
4545
uses: ./.github/actions/install-latest-npm
4646
with:
@@ -119,8 +119,8 @@ jobs:
119119
uses: actions/setup-node@v4
120120
id: node
121121
with:
122-
node-version: 22.x
123-
check-latest: contains('22.x', '.x')
122+
node-version: 24.x
123+
check-latest: contains('24.x', '.x')
124124
- name: Install Latest npm
125125
uses: ./.github/actions/install-latest-npm
126126
with:

package.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
"cov:test": "TAP_FLAGS='--cov' npm run test:code",
1616
"test:code": "tap ${TAP_FLAGS:-'--'} test/*.js",
1717
"test:style": "standard",
18-
"test": "tap",
18+
"test": "node --test './test/**/*.js'",
1919
"lint": "npm run eslint",
2020
"postlint": "template-oss-check",
2121
"template-oss-apply": "template-oss-apply --force",
2222
"lintfix": "npm run eslint -- --fix",
23-
"snap": "tap",
23+
"snap": "node --test --test-update-snapshots './test/**/*.js'",
2424
"posttest": "npm run lint",
25-
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
25+
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
26+
"test:node20": "node --test test",
27+
"test:cover": "node --test --experimental-test-coverage --test-timeout=3000 --test-coverage-lines=100 --test-coverage-functions=100 --test-coverage-branches=100 './test/**/*.js'"
2628
},
2729
"repository": {
2830
"type": "git",
@@ -50,12 +52,8 @@
5052
"templateOSS": {
5153
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
5254
"version": "4.28.1",
53-
"publish": true
54-
},
55-
"tap": {
56-
"nyc-arg": [
57-
"--exclude",
58-
"tap-snapshots/**"
59-
]
55+
"publish": true,
56+
"testRunner": "node:test",
57+
"latestCiVersion": 24
6058
}
6159
}

test/index.js

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,159 @@
11
'use strict'
22

3-
var validate = require('..')
4-
var test = require('tap').test
3+
const { test } = require('node:test')
4+
const assert = require('node:assert')
5+
const validate = require('..')
56

6-
test('validate-npm-package-name', function (t) {
7+
test('validate-npm-package-name', function () {
78
// Traditional
89

9-
t.same(validate('some-package'), { validForNewPackages: true, validForOldPackages: true })
10-
t.same(validate('example.com'), { validForNewPackages: true, validForOldPackages: true })
11-
t.same(validate('under_score'), { validForNewPackages: true, validForOldPackages: true })
12-
t.same(validate('period.js'), { validForNewPackages: true, validForOldPackages: true })
13-
t.same(validate('123numeric'), { validForNewPackages: true, validForOldPackages: true })
14-
t.same(validate('crazy!'), {
10+
assert.deepStrictEqual(validate('some-package'), { validForNewPackages: true, validForOldPackages: true })
11+
assert.deepStrictEqual(validate('example.com'), { validForNewPackages: true, validForOldPackages: true })
12+
assert.deepStrictEqual(validate('under_score'), { validForNewPackages: true, validForOldPackages: true })
13+
assert.deepStrictEqual(validate('period.js'), { validForNewPackages: true, validForOldPackages: true })
14+
assert.deepStrictEqual(validate('123numeric'), { validForNewPackages: true, validForOldPackages: true })
15+
assert.deepStrictEqual(validate('crazy!'), {
1516
validForNewPackages: false,
1617
validForOldPackages: true,
1718
warnings: ['name can no longer contain special characters ("~\'!()*")'],
1819
})
1920

2021
// Scoped (npm 2+)
2122

22-
t.same(validate('@npm/thingy'), { validForNewPackages: true, validForOldPackages: true })
23-
t.same(validate('@npm-zors/money!time.js'), {
23+
assert.deepStrictEqual(validate('@npm/thingy'), { validForNewPackages: true, validForOldPackages: true })
24+
assert.deepStrictEqual(validate('@npm-zors/money!time.js'), {
2425
validForNewPackages: false,
2526
validForOldPackages: true,
2627
warnings: ['name can no longer contain special characters ("~\'!()*")'],
2728
})
2829

2930
// Scoped package validation - only period start is checked, everything else is allowed
3031

31-
t.same(validate('@user/node_modules'), {
32+
assert.deepStrictEqual(validate('@user/node_modules'), {
3233
validForNewPackages: true,
3334
validForOldPackages: true,
3435
})
3536

36-
t.same(validate('@user/_package'), {
37+
assert.deepStrictEqual(validate('@user/_package'), {
3738
validForNewPackages: true,
3839
validForOldPackages: true,
3940
})
4041

41-
t.same(validate('@user/http'), {
42+
assert.deepStrictEqual(validate('@user/http'), {
4243
validForNewPackages: true,
4344
validForOldPackages: true,
4445
})
4546

4647
// Invalid
4748

48-
t.same(validate(null), {
49+
assert.deepStrictEqual(validate(null), {
4950
validForNewPackages: false,
5051
validForOldPackages: false,
5152
errors: ['name cannot be null'] })
5253

53-
t.same(validate(undefined), {
54+
assert.deepStrictEqual(validate(undefined), {
5455
validForNewPackages: false,
5556
validForOldPackages: false,
5657
errors: ['name cannot be undefined'] })
5758

58-
t.same(validate(42), {
59+
assert.deepStrictEqual(validate(42), {
5960
validForNewPackages: false,
6061
validForOldPackages: false,
6162
errors: ['name must be a string'] })
6263

63-
t.same(validate(''), {
64+
assert.deepStrictEqual(validate(''), {
6465
validForNewPackages: false,
6566
validForOldPackages: false,
6667
errors: ['name length must be greater than zero'] })
6768

68-
t.same(validate('.start-with-period'), {
69+
assert.deepStrictEqual(validate('.start-with-period'), {
6970
validForNewPackages: false,
7071
validForOldPackages: false,
7172
errors: ['name cannot start with a period'] })
7273

73-
t.same(validate('@npm/.'), {
74+
assert.deepStrictEqual(validate('@npm/.'), {
7475
validForNewPackages: false,
7576
validForOldPackages: false,
7677
errors: ['name cannot start with a period'] })
7778

78-
t.same(validate('@npm/..'), {
79+
assert.deepStrictEqual(validate('@npm/..'), {
7980
validForNewPackages: false,
8081
validForOldPackages: false,
8182
errors: ['name cannot start with a period'] })
8283

83-
t.same(validate('@npm/.package'), {
84+
assert.deepStrictEqual(validate('@npm/.package'), {
8485
validForNewPackages: false,
8586
validForOldPackages: false,
8687
errors: ['name cannot start with a period'] })
8788

88-
t.same(validate('_start-with-underscore'), {
89+
assert.deepStrictEqual(validate('_start-with-underscore'), {
8990
validForNewPackages: false,
9091
validForOldPackages: false,
9192
errors: ['name cannot start with an underscore'] })
9293

93-
t.same(validate('contain:colons'), {
94+
assert.deepStrictEqual(validate('contain:colons'), {
9495
validForNewPackages: false,
9596
validForOldPackages: false,
9697
errors: ['name can only contain URL-friendly characters'] })
9798

98-
t.same(validate(' leading-space'), {
99+
assert.deepStrictEqual(validate(' leading-space'), {
99100
validForNewPackages: false,
100101
validForOldPackages: false,
101102
/* eslint-disable-next-line max-len */
102103
errors: ['name cannot contain leading or trailing spaces', 'name can only contain URL-friendly characters'] })
103104

104-
t.same(validate('trailing-space '), {
105+
assert.deepStrictEqual(validate('trailing-space '), {
105106
validForNewPackages: false,
106107
validForOldPackages: false,
107108
/* eslint-disable-next-line max-len */
108109
errors: ['name cannot contain leading or trailing spaces', 'name can only contain URL-friendly characters'] })
109110

110-
t.same(validate('s/l/a/s/h/e/s'), {
111+
assert.deepStrictEqual(validate('s/l/a/s/h/e/s'), {
111112
validForNewPackages: false,
112113
validForOldPackages: false,
113114
errors: ['name can only contain URL-friendly characters'] })
114115

115-
t.same(validate('node_modules'), {
116+
assert.deepStrictEqual(validate('node_modules'), {
116117
validForNewPackages: false,
117118
validForOldPackages: false,
118119
errors: ['node_modules is not a valid package name'] })
119120

120-
t.same(validate('favicon.ico'), {
121+
assert.deepStrictEqual(validate('favicon.ico'), {
121122
validForNewPackages: false,
122123
validForOldPackages: false,
123124
errors: ['favicon.ico is not a valid package name'] })
124125

125126
// Node/IO Core
126127

127-
t.same(validate('http'), {
128+
assert.deepStrictEqual(validate('http'), {
128129
validForNewPackages: false,
129130
validForOldPackages: true,
130131
warnings: ['http is a core module name'] })
131132

132-
t.deepEqual(validate('process'), {
133+
assert.deepStrictEqual(validate('process'), {
133134
validForNewPackages: false,
134135
validForOldPackages: true,
135136
warnings: ['process is a core module name'] })
136137

137138
// Long Package Names
138139

139140
/* eslint-disable-next-line max-len */
140-
t.same(validate('ifyouwanttogetthesumoftwonumberswherethosetwonumbersarechosenbyfindingthelargestoftwooutofthreenumbersandsquaringthemwhichismultiplyingthembyitselfthenyoushouldinputthreenumbersintothisfunctionanditwilldothatforyou-'), {
141+
assert.deepStrictEqual(validate('ifyouwanttogetthesumoftwonumberswherethosetwonumbersarechosenbyfindingthelargestoftwooutofthreenumbersandsquaringthemwhichismultiplyingthembyitselfthenyoushouldinputthreenumbersintothisfunctionanditwilldothatforyou-'), {
141142
validForNewPackages: false,
142143
validForOldPackages: true,
143144
warnings: ['name can no longer contain more than 214 characters'],
144145
})
145146

146147
/* eslint-disable-next-line max-len */
147-
t.same(validate('ifyouwanttogetthesumoftwonumberswherethosetwonumbersarechosenbyfindingthelargestoftwooutofthreenumbersandsquaringthemwhichismultiplyingthembyitselfthenyoushouldinputthreenumbersintothisfunctionanditwilldothatforyou'), {
148+
assert.deepStrictEqual(validate('ifyouwanttogetthesumoftwonumberswherethosetwonumbersarechosenbyfindingthelargestoftwooutofthreenumbersandsquaringthemwhichismultiplyingthembyitselfthenyoushouldinputthreenumbersintothisfunctionanditwilldothatforyou'), {
148149
validForNewPackages: true,
149150
validForOldPackages: true,
150151
})
151152

152153
// Legacy Mixed-Case
153154

154-
t.same(validate('CAPITAL-LETTERS'), {
155+
assert.deepStrictEqual(validate('CAPITAL-LETTERS'), {
155156
validForNewPackages: false,
156157
validForOldPackages: true,
157158
warnings: ['name can no longer contain capital letters'] })
158-
159-
t.end()
160159
})

0 commit comments

Comments
 (0)