Skip to content

Commit 5d9004e

Browse files
adjust hello.test.js
1 parent 0bdaaa7 commit 5d9004e

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/test/util.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export const getNodeVersion = () => {
3939
type TestTreeExpectation = [string, TestTreeExpectation[]?];
4040

4141
const buildTreeExpectation = (entry: TestTreeExpectation, c: vscode.TestItemCollection) => {
42-
for (const [id, { children }] of c) {
43-
const node: TestTreeExpectation = [id];
42+
for (const [, { children, label }] of c) {
43+
const node: TestTreeExpectation = [label];
4444
buildTreeExpectation(node, children);
4545
if (entry.length === 1) {
4646
entry[1] = [node];
@@ -112,9 +112,9 @@ export class FakeTestRun implements vscode.TestRun {
112112
public expectStates(expected: { [test: string]: TestState[] }) {
113113
const actual: { [test: string]: TestState[] } = {};
114114
for (const { test, state } of this.states) {
115-
let key = test.id;
115+
let key = test.label;
116116
for (let p = test.parent; p; p = p.parent) {
117-
key = `${p.id}/${key}`;
117+
key = `${p.label}/${key}`;
118118
}
119119
(actual[key] ??= []).push(state);
120120
}
@@ -171,7 +171,7 @@ export class FakeTestRun implements vscode.TestRun {
171171
end(): void {
172172
this.ended = true;
173173
}
174-
addCoverage(fileCoverage: vscode.FileCoverage): void {}
174+
addCoverage(fileCoverage: vscode.FileCoverage): void { }
175175
onDidDispose = new vscode.EventEmitter<void>().event;
176176
//#endregion
177177
}

testCases/simple/runner.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ it("discovers tests", async () => {
1515
const c = await getController();
1616

1717
await expectTestTree(c, [
18-
["hello.test.js", [["math", [["addition"], ["subtraction"]]]]],
18+
["hello.test.js", [["math", [["addition"]]], ["math", [["subtraction"]]]]],
1919
["otherFolder", [["some.test.js", [["addition"]]]]],
2020
["test", [["inAFolder.js", [["addition"]]]]],
2121
["test-WithADash.js", [["addition"]]],
@@ -52,7 +52,7 @@ it("cleans up folder if all child files are deleted", () =>
5252
await onChange;
5353

5454
await expectTestTree(c, [
55-
["hello.test.js", [["math", [["addition"], ["subtraction"]]]]],
55+
["hello.test.js", [["math", [["addition"]]], ["math", [["subtraction"]]]]],
5656
["otherFolder", [["some.test.js", [["addition"]]]]],
5757
["test-WithADash.js", [["addition"]]],
5858
["test.js", [["addition"]]],
@@ -98,7 +98,7 @@ it("runs tests", async () => {
9898
"test-WithADash.js/addition": ["started", "passed"],
9999
"test.js/addition": ["started", "passed"],
100100
"withADashTheOtherWay-test.js/addition": ["started", "failed"],
101-
"hello.test.js/math": ["started", "passed"],
101+
"hello.test.js/math": ["started", "passed", "started", "passed"],
102102
"hello.test.js/math/addition": ["started", "passed"],
103103
"hello.test.js/math/subtraction": ["started", "passed"],
104104
"otherFolder/some.test.js/addition": ["started", "passed"],
@@ -126,7 +126,7 @@ it("runs tests in a file", async () => {
126126
);
127127

128128
run.expectStates({
129-
"hello.test.js/math": ["started", "passed"],
129+
"hello.test.js/math": ["started", "passed", "started", "passed"],
130130
"hello.test.js/math/addition": ["started", "passed"],
131131
"hello.test.js/math/subtraction": ["started", "passed"],
132132
"withADot.test.js/addition": ["started", "passed"],
@@ -145,7 +145,7 @@ it("runs subsets of tests", async () => {
145145
const nodeVersion = getNodeVersion();
146146
if (nodeVersion < 22) {
147147
run.expectStates({
148-
"hello.test.js/math": ["started", "passed"],
148+
"hello.test.js/math": ["started", "passed", "started", "passed"],
149149
"hello.test.js/math/addition": ["started", "passed"],
150150
// did not work in earlier versions due to nodejs/node#51577
151151
"hello.test.js/math/subtraction": ["started", "passed"],
@@ -279,7 +279,7 @@ it("handles test excludes", async () => {
279279
c,
280280
new vscode.TestRunRequest(
281281
[c.ctrl.items.get("hello.test.js")!],
282-
[c.ctrl.items.get("hello.test.js")!.children.get("math")!.children.get("subtraction")!],
282+
[c.ctrl.items.get("hello.test.js")!.children.get("math#0")!.children.get("subtraction")!],
283283
),
284284
);
285285

@@ -343,7 +343,7 @@ it("shows test output", async () => {
343343
},
344344
{
345345
output: "another log",
346-
location: new vscode.Location(uri, new vscode.Position(10, 20)),
346+
location: new vscode.Location(uri, new vscode.Position(12, 20)),
347347
test: undefined,
348348
},
349349
],

testCases/simple/workspace/hello.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ describe("math", () => {
66
console.log("some log");
77
strictEqual(1 + 1, 2);
88
});
9+
});
910

11+
describe("math", () => {
1012
it(`subtraction`, async () => {
1113
process.stdout.write("another log");
1214
strictEqual(1 - 1, 0);

0 commit comments

Comments
 (0)