Skip to content

Commit 509ae0a

Browse files
committed
Move to the Node.js built-in test runner
This is the first step towards moving this package to use native JS modules instead of CommonJS. Jest does not support mocking native JS modules, so we move to the built-in Node.js test runner instead. This requires using Node.js v24, as that's the first version that supports mocking JSON modules. It also requires using --experimental-test-module-mocks, which is a bit unfortunate, but at least we're only using it during testing.
1 parent a4246ec commit 509ae0a

27 files changed

+1613
-4468
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- uses: actions/checkout@v4
1919
- uses: actions/setup-node@v4
2020
with:
21-
node-version: lts/*
21+
node-version: 24
2222
- run: npm install
2323
- run: npm run lint
2424
- run: npm test

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/coverage/
1+
/lcov.info
22
/node_modules/
33
/sg/
44
/private-config.json

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:22.16.0-bookworm-slim
1+
FROM node:24.1.0-bookworm-slim
22

33
WORKDIR /app
44

__tests__/.eslintrc.json

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

__tests__/__setup__.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as path from "node:path";
2+
import { snapshot } from "node:test";
3+
4+
snapshot.setResolveSnapshotPath(testFilePath => {
5+
const base = path.dirname(testFilePath);
6+
const filename = path.basename(testFilePath);
7+
return path.resolve(base, "__snapshots__", `${filename}.snap`);
8+
});

__tests__/__snapshots__/get-user-status.js.snap renamed to __tests__/__snapshots__/get-user-status.mjs.snap

Lines changed: 192 additions & 194 deletions
Large diffs are not rendered by default.

__tests__/__snapshots__/pr-webhook.js.snap

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
exports[`A PR from a branch must trigger an appropriate status update 1`] = `
2+
{
3+
"arguments": [
4+
{
5+
"owner": "whatwg",
6+
"repo": "console",
7+
"sha": "80a564b821732bebe6ea082db7c699389ecf4716",
8+
"statusField1": "status value 1",
9+
"statusField2": "status value 2"
10+
}
11+
],
12+
"stack": {},
13+
"this": {}
14+
}
15+
`;
16+
17+
exports[`A PR from a fork must trigger an appropriate status update 1`] = `
18+
{
19+
"arguments": [
20+
{
21+
"owner": "whatwg",
22+
"repo": "console",
23+
"sha": "0744fdd6281170d629cee5c6bc26eda1b8ebdb95",
24+
"statusField1": "status value 1",
25+
"statusField2": "status value 2"
26+
}
27+
],
28+
"stack": {},
29+
"this": {}
30+
}
31+
`;
Original file line numberDiff line numberDiff line change
@@ -1,178 +1,176 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
2-
3-
exports[`An entity with a scope of "all" must transform appropriately 1`] = `
1+
exports[`An entity with a scope of \"all\" must transform appropriately 1`] = `
42
{
5-
"privateData": null,
3+
"type": "entity",
64
"publicData": {
75
"id": "1d8ab899-4d91-48b8-acfa-bf9cde5ad909",
6+
"verified": false,
7+
"workstreams": "all",
88
"info": {
9+
"name": "Contoso Ltd.",
910
"address": "123 Main Street, New York, NY, USA",
11+
"url": "https://contoso.com/",
12+
"gitHubOrganization": "contoso",
1013
"contact1": {
11-
"email": "[email protected]",
12-
"gitHubID": "ellencontoso",
1314
"name": "Ellen Adams",
15+
"email": "[email protected]",
16+
"gitHubID": "ellencontoso"
1417
},
1518
"contact2": {
16-
"email": "[email protected]",
17-
"gitHubID": "lisacontoso",
1819
"name": "Lisa Andrews",
19-
},
20-
"gitHubOrganization": "contoso",
21-
"name": "Contoso Ltd.",
22-
"url": "https://contoso.com/",
20+
"email": "[email protected]",
21+
"gitHubID": "lisacontoso"
22+
}
2323
},
2424
"signature": {
25-
"signedAt": "1970-01-01T00:00:00.000Z",
2625
"signedBy": "Domenic Denicola",
2726
"signedByTitle": "Software engineer",
28-
},
29-
"verified": false,
30-
"workstreams": "all",
27+
"signedAt": "1970-01-01T00:00:00.000Z"
28+
}
3129
},
32-
"type": "entity",
30+
"privateData": null
3331
}
3432
`;
3533

3634
exports[`An entity with an array of known scopes must transform appropriately 1`] = `
3735
{
38-
"privateData": null,
36+
"type": "entity",
3937
"publicData": {
4038
"id": "1d8ab899-4d91-48b8-acfa-bf9cde5ad909",
39+
"verified": false,
40+
"workstreams": [
41+
"compat",
42+
"console",
43+
"xhr"
44+
],
4145
"info": {
46+
"name": "Contoso Ltd.",
4247
"address": "123 Main Street, New York, NY, USA",
48+
"url": "https://contoso.com/",
49+
"gitHubOrganization": "contoso",
4350
"contact1": {
44-
"email": "[email protected]",
45-
"gitHubID": "ellencontoso",
4651
"name": "Ellen Adams",
52+
"email": "[email protected]",
53+
"gitHubID": "ellencontoso"
4754
},
4855
"contact2": {
49-
"email": "[email protected]",
50-
"gitHubID": "lisacontoso",
5156
"name": "Lisa Andrews",
52-
},
53-
"gitHubOrganization": "contoso",
54-
"name": "Contoso Ltd.",
55-
"url": "https://contoso.com/",
57+
"email": "[email protected]",
58+
"gitHubID": "lisacontoso"
59+
}
5660
},
5761
"signature": {
58-
"signedAt": "1970-01-01T00:00:00.000Z",
5962
"signedBy": "Domenic Denicola",
6063
"signedByTitle": "Software engineer",
61-
},
62-
"verified": false,
63-
"workstreams": [
64-
"compat",
65-
"console",
66-
"xhr",
67-
],
64+
"signedAt": "1970-01-01T00:00:00.000Z"
65+
}
6866
},
69-
"type": "entity",
67+
"privateData": null
7068
}
7169
`;
7270

7371
exports[`An individual selecting a single known workstream must transform appropriately 1`] = `
7472
{
75-
"privateData": {
76-
"id": "1d8ab899-4d91-48b8-acfa-bf9cde5ad909",
77-
"info": {
78-
"address": "New York, NY, USA",
79-
"email": "[email protected]",
80-
},
81-
},
73+
"type": "individual",
8274
"publicData": {
8375
"id": "1d8ab899-4d91-48b8-acfa-bf9cde5ad909",
76+
"verified": false,
77+
"workstreams": [
78+
"html"
79+
],
8480
"info": {
85-
"gitHubID": "domenic",
8681
"name": "Domenic Denicola",
82+
"gitHubID": "domenic"
8783
},
8884
"signature": {
89-
"signedAt": "1970-01-01T00:00:00.000Z",
90-
},
91-
"verified": false,
92-
"workstreams": [
93-
"html",
94-
],
85+
"signedAt": "1970-01-01T00:00:00.000Z"
86+
}
9587
},
96-
"type": "individual",
97-
}
98-
`;
99-
100-
exports[`An individual with a scope of "all" must transform appropriately 1`] = `
101-
{
10288
"privateData": {
10389
"id": "1d8ab899-4d91-48b8-acfa-bf9cde5ad909",
10490
"info": {
10591
"address": "New York, NY, USA",
106-
"email": "[email protected]",
107-
},
108-
},
92+
"email": "[email protected]"
93+
}
94+
}
95+
}
96+
`;
97+
98+
exports[`An individual with a scope of \"all\" must transform appropriately 1`] = `
99+
{
100+
"type": "individual",
109101
"publicData": {
110102
"id": "1d8ab899-4d91-48b8-acfa-bf9cde5ad909",
103+
"verified": false,
104+
"workstreams": "all",
111105
"info": {
112-
"gitHubID": "domenic",
113106
"name": "Domenic Denicola",
107+
"gitHubID": "domenic"
114108
},
115109
"signature": {
116-
"signedAt": "1970-01-01T00:00:00.000Z",
117-
},
118-
"verified": false,
119-
"workstreams": "all",
110+
"signedAt": "1970-01-01T00:00:00.000Z"
111+
}
120112
},
121-
"type": "individual",
113+
"privateData": {
114+
"id": "1d8ab899-4d91-48b8-acfa-bf9cde5ad909",
115+
"info": {
116+
"address": "New York, NY, USA",
117+
"email": "[email protected]"
118+
}
119+
}
122120
}
123121
`;
124122

125123
exports[`An individual with an array of known scopes must transform appropriately 1`] = `
126124
{
127-
"privateData": {
128-
"id": "1d8ab899-4d91-48b8-acfa-bf9cde5ad909",
129-
"info": {
130-
"address": "New York, NY, USA",
131-
"email": "[email protected]",
132-
},
133-
},
125+
"type": "individual",
134126
"publicData": {
135127
"id": "1d8ab899-4d91-48b8-acfa-bf9cde5ad909",
136-
"info": {
137-
"gitHubID": "domenic",
138-
"name": "Domenic Denicola",
139-
},
140-
"signature": {
141-
"signedAt": "1970-01-01T00:00:00.000Z",
142-
},
143128
"verified": false,
144129
"workstreams": [
145130
"compat",
146131
"console",
147-
"xhr",
132+
"xhr"
148133
],
134+
"info": {
135+
"name": "Domenic Denicola",
136+
"gitHubID": "domenic"
137+
},
138+
"signature": {
139+
"signedAt": "1970-01-01T00:00:00.000Z"
140+
}
149141
},
150-
"type": "individual",
142+
"privateData": {
143+
"id": "1d8ab899-4d91-48b8-acfa-bf9cde5ad909",
144+
"info": {
145+
"address": "New York, NY, USA",
146+
"email": "[email protected]"
147+
}
148+
}
151149
}
152150
`;
153151

154152
exports[`An invited individual with invited as their workstreams must transform appropriately 1`] = `
155153
{
156-
"privateData": {
157-
"id": "1d8ab899-4d91-48b8-acfa-bf9cde5ad909",
158-
"info": {
159-
"address": "New York, NY, USA",
160-
"email": "[email protected]",
161-
},
162-
},
154+
"type": "individual",
163155
"publicData": {
164156
"id": "1d8ab899-4d91-48b8-acfa-bf9cde5ad909",
157+
"verified": false,
158+
"workstreams": "Verifier: replace this with the array of workstreams the SG has invited this individual to, or replace it with \\"all\\" if they're invited to all workstreams.",
165159
"info": {
166-
"gitHubID": "domenic",
167160
"name": "Domenic Denicola",
161+
"gitHubID": "domenic"
168162
},
169-
"invited": true,
170163
"signature": {
171-
"signedAt": "1970-01-01T00:00:00.000Z",
164+
"signedAt": "1970-01-01T00:00:00.000Z"
172165
},
173-
"verified": false,
174-
"workstreams": "Verifier: replace this with the array of workstreams the SG has invited this individual to, or replace it with "all" if they're invited to all workstreams.",
166+
"invited": true
175167
},
176-
"type": "individual",
168+
"privateData": {
169+
"id": "1d8ab899-4d91-48b8-acfa-bf9cde5ad909",
170+
"info": {
171+
"address": "New York, NY, USA",
172+
"email": "[email protected]"
173+
}
174+
}
177175
}
178176
`;

0 commit comments

Comments
 (0)