Skip to content

Commit a490ae2

Browse files
committed
fix: add node 22 support
1 parent 607239e commit a490ae2

File tree

12 files changed

+235
-122
lines changed

12 files changed

+235
-122
lines changed

.github/workflows/ci.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
jobs:
1212
test:
1313
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node-version: [20, 22]
1417

1518
steps:
1619
- name: Checkout code
@@ -19,7 +22,7 @@ jobs:
1922
- name: Setup Node.js environment
2023
uses: actions/setup-node@v2
2124
with:
22-
node-version: '21'
25+
node-version: ${{ matrix.node-version }}
2326

2427
- name: Install dependencies
2528
run: npm ci

package-lock.json

+14-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
"@types/picomatch": "^2.3.3",
195195
"@types/sinon": "^17.0.3",
196196
"@types/split2": "^4.2.3",
197-
"@types/vscode": "^1.86.0",
197+
"@types/vscode": "^1.88.0",
198198
"@types/ws": "^8.5.10",
199199
"@vscode/test-electron": "^2.3.9",
200200
"acorn": "^8.11.3",
@@ -204,7 +204,7 @@
204204
"mocha": "^10.3.0",
205205
"prettier": "^3.2.5",
206206
"sinon": "^17.0.1",
207-
"tsx": "^4.7.1",
207+
"tsx": "^4.7.3",
208208
"typescript": "^5.4.2",
209209
"vitest": "^1.3.1"
210210
},

src/controller.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ICreateOpts, ItemType, getContainingItemsForFile, testMetadata } from "
1010
import { IParsedNode, parseSource } from "./parsing";
1111
import { RunHandler, TestRunner } from "./runner";
1212
import { ISourceMapMaintainer, SourceMapStore } from "./source-map-store";
13+
import { ExtensionConfig } from './extension-config';
1314

1415
const diagnosticCollection = vscode.languages.createDiagnosticCollection("nodejs-testing-dupes");
1516

src/ExtensionConfig.ts renamed to src/extension-config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
interface ExtensionConfig {
1+
export interface ExtensionConfig {
22
extensions: string[];
33
filePatterns?: string[];
44
parameters: string[];

src/metadata.ts

+20
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,23 @@ export function* getContainingItemsForFile(
5454
}
5555
}
5656
}
57+
58+
export function getFullTestName(test: vscode.TestItem) {
59+
let name = test.label;
60+
while (test.parent && testMetadata.get(test.parent)?.type === ItemType.Test) {
61+
test = test.parent;
62+
name = `${test.label} ${name}`;
63+
}
64+
65+
return name;
66+
}
67+
68+
export function isParent(possibleParent: vscode.TestItem, possibleChild: vscode.TestItem) {
69+
for (let t: vscode.TestItem | undefined = possibleChild; t; t = t.parent) {
70+
if (t === possibleParent) {
71+
return true;
72+
}
73+
}
74+
75+
return false;
76+
}

src/runner-protocol.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ export const contract = makeContract({
7474
// the interface for servers to interact with clients
7575
client: {
7676
kill: notificationType({}),
77+
version: requestType({
78+
params: s.sNull(),
79+
result: s.sString(),
80+
}),
7781
start: requestType({
7882
params: s.sObject({
7983
verbose: s.sBoolean(),
@@ -101,10 +105,7 @@ export const contract = makeContract({
101105
),
102106
extraEnv: s.sMap(s.sString()),
103107
}),
104-
result: s.sObject({
105-
status: s.sNumber(),
106-
message: s.optionalProp(s.sString()),
107-
}),
108+
result: s.sNull(),
108109
}),
109110
},
110111
});
@@ -118,11 +119,6 @@ export type ITestRunResult = (typeof contract)["client"]["start"]["resultSeriali
118119

119120
export type ILog = (typeof log)["T"];
120121

121-
export const enum CompleteStatus {
122-
Done,
123-
NodeVersionOutdated,
124-
}
125-
126122
export const enum Result {
127123
Ok,
128124
Skipped,

src/runner-worker.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import split from "split2";
99
import { StackFrame } from "stacktrace-parser";
1010
import { pathToFileURL } from "url";
1111
import { WebSocket } from "ws";
12+
import { ExtensionConfig } from "./extension-config";
1213
import { escapeRegex } from "./regex";
13-
import { CompleteStatus, ITestRunFile, JsonFromReporter, contract } from "./runner-protocol";
14+
import { ITestRunFile, JsonFromReporter, contract } from "./runner-protocol";
1415

1516
const colors = [
1617
ansiColors.redBright,
@@ -45,19 +46,14 @@ const start: (typeof contract)["TClientHandler"]["start"] = async ({
4546
extraEnv,
4647
coverageDir,
4748
}) => {
48-
const majorVersion = /^v([0-9]+)/.exec(process.version);
49-
if (!majorVersion || Number(majorVersion[1]) < 19) {
50-
return { status: CompleteStatus.NodeVersionOutdated, message: process.version };
51-
}
52-
5349
const todo: Promise<void>[] = [];
5450
for (let i = 0; i < concurrency && i < files.length; i++) {
5551
const prefix = colors[i % colors.length](`worker${i + 1}> `);
5652
todo.push(doWork(prefix, files, extensions, verbose, extraEnv, coverageDir));
5753
}
5854
await Promise.all(todo);
5955

60-
return { status: CompleteStatus.Done };
56+
return null;
6157
};
6258

6359
async function doWork(
@@ -90,7 +86,7 @@ async function doWork(
9086

9187
args.push(next.path);
9288
if (verbose) {
93-
server.output(`${prefix}${path.basename(process.argv0)} ${args.join('" "')}`);
89+
server.output(`${prefix}${process.argv0} ${args.join('" "')}`);
9490
}
9591

9692
const cp = spawn(process.argv0, args, {
@@ -282,5 +278,5 @@ const { server } = Contract.getServerFromStream(
282278
contract,
283279
new NodeJsMessageStream(socket, socket),
284280
{},
285-
{ start, kill: () => process.exit() },
281+
{ start, kill: () => process.exit(), version: () => Promise.resolve(process.version) },
286282
);

0 commit comments

Comments
 (0)