Skip to content

Commit fe21b98

Browse files
committed
test(): update test usage after upgrade jest to v30
1 parent 37cc57a commit fe21b98

File tree

9 files changed

+65
-63
lines changed

9 files changed

+65
-63
lines changed

packages/cook/src/cook.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ describe("evaluate", () => {
205205
if (!typescript && !containsExperimental(source)) {
206206
expect(() =>
207207
equivalentFunc(source, attemptToVisitGlobals)(...cloneDeep(args))
208-
).toThrowError();
208+
).toThrow();
209209
}
210210
expect(() => func(...cloneDeep(args))).toThrowErrorMatchingSnapshot();
211211
}
@@ -242,7 +242,7 @@ describe("evaluate", () => {
242242
return a;
243243
}
244244
`;
245-
expect(() => equivalentFunc(source, new Set())).not.toThrowError();
245+
expect(() => equivalentFunc(source, new Set())).not.toThrow();
246246
const { function: funcAst, attemptToVisitGlobals } =
247247
precookFunction(source);
248248
const globalVariables = supply(
@@ -271,7 +271,7 @@ describe("evaluate", () => {
271271
if (!containsExperimental(source)) {
272272
expect(() =>
273273
equivalentFunc(source, attemptToVisitGlobals, true)
274-
).toThrowError();
274+
).toThrow();
275275
}
276276
expect(() =>
277277
cook(exprAst, source, { globalVariables })
@@ -423,7 +423,7 @@ describe("evaluate", () => {
423423
return "abc".replace(reg, "");
424424
}
425425
`;
426-
expect(() => equivalentFunc(source, new Set())).not.toThrowError();
426+
expect(() => equivalentFunc(source, new Set())).not.toThrow();
427427
const { function: funcAst, attemptToVisitGlobals } =
428428
precookFunction(source);
429429
const globalVariables = supply(

packages/element/src/NextElement.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ describe("NextElement", () => {
409409
"change",
410410
]);
411411

412-
// `expect(...).toThrowError()` does not work for decorators.
412+
// `expect(...).toThrow()` does not work for decorators.
413413
let message: string | undefined;
414414
try {
415415
element.overrideEvent();

packages/react-element/src/ReactNextElement.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,6 @@ describe("ReactNextElement", () => {
301301
expect(element.shadowRoot).toBeFalsy();
302302
expect(() => {
303303
element.connectedCallback();
304-
}).toThrowError();
304+
}).toThrow();
305305
});
306306
});

packages/runtime/src/CustomProcessors.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ describe("CustomProcessors", () => {
3030
// Can't register duplicated processors in the same namespace.
3131
expect(() => {
3232
customProcessors.define("brickKit.objectEntries", () => void 0);
33-
}).toThrowError();
33+
}).toThrow();
3434
});
3535
});

packages/runtime/src/createRoot.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ describe("preview", () => {
240240
]);
241241

242242
expect(container.innerHTML).toBe(
243-
'<div data-error-boundary=""><div>UNKNOWN_ERROR: ReferenceError: QUERY is not defined, in "&lt;% QUERY.q %&gt;"</div></div>'
243+
'<div data-error-boundary="" style="color: var(--color-error);"><div>UNKNOWN_ERROR: ReferenceError: QUERY is not defined, in "&lt;% QUERY.q %&gt;"</div></div>'
244244
);
245245
expect(portal.innerHTML).toBe("");
246246
expect(applyTheme).not.toHaveBeenCalled();

packages/runtime/src/internal/Runtime.spec.ts

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -983,28 +983,29 @@ describe("Runtime", () => {
983983
getHistory().push("/app-a/sub-routes/3");
984984
await (global as any).flushPromises();
985985
expect(document.body.children).toMatchInlineSnapshot(`
986-
HTMLCollection [
987-
<div
988-
id="main-mount-point"
989-
>
990-
<h1>
991-
Hello
992-
</h1>
993-
<div>
994-
<div
995-
data-error-boundary=""
996-
>
997-
<div>
998-
Oops! Something went wrong: SyntaxError: Unexpected parseExpression() input: The input should contain exactly one expression, but the first expression is followed by the unexpected character \`3\`. (1:4), in "&lt;% Sub 3 %&gt;"
999-
</div>
1000-
</div>
1001-
</div>
1002-
</div>,
1003-
<div
1004-
id="portal-mount-point"
1005-
/>,
1006-
]
1007-
`);
986+
HTMLCollection [
987+
<div
988+
id="main-mount-point"
989+
>
990+
<h1>
991+
Hello
992+
</h1>
993+
<div>
994+
<div
995+
data-error-boundary=""
996+
style="color: var(--color-error);"
997+
>
998+
<div>
999+
Oops! Something went wrong: SyntaxError: Unexpected parseExpression() input: The input should contain exactly one expression, but the first expression is followed by the unexpected character \`3\`. (1:4), in "&lt;% Sub 3 %&gt;"
1000+
</div>
1001+
</div>
1002+
</div>
1003+
</div>,
1004+
<div
1005+
id="portal-mount-point"
1006+
/>,
1007+
]
1008+
`);
10081009
expect(consoleError).toHaveBeenCalledTimes(1);
10091010
expect(getRuntime().getNavConfig()).toEqual({
10101011
breadcrumb: [{ text: "0" }],
@@ -1514,28 +1515,29 @@ describe("Runtime", () => {
15141515
await (global as any).flushPromises();
15151516
await new Promise((resolve) => setTimeout(resolve));
15161517
expect(document.body.children).toMatchInlineSnapshot(`
1517-
HTMLCollection [
1518-
<div
1519-
id="main-mount-point"
1520-
>
1521-
<h1>
1522-
Sub-routes with error
1523-
</h1>
1524-
<div>
1525-
<div
1526-
data-error-boundary=""
1527-
>
1528-
<div>
1529-
Oops! Something went wrong: oops
1530-
</div>
1531-
</div>
1532-
</div>
1533-
</div>,
1534-
<div
1535-
id="portal-mount-point"
1536-
/>,
1537-
]
1538-
`);
1518+
HTMLCollection [
1519+
<div
1520+
id="main-mount-point"
1521+
>
1522+
<h1>
1523+
Sub-routes with error
1524+
</h1>
1525+
<div>
1526+
<div
1527+
data-error-boundary=""
1528+
style="color: var(--color-error);"
1529+
>
1530+
<div>
1531+
Oops! Something went wrong: oops
1532+
</div>
1533+
</div>
1534+
</div>
1535+
</div>,
1536+
<div
1537+
id="portal-mount-point"
1538+
/>,
1539+
]
1540+
`);
15391541
expect(consoleError).toHaveBeenCalledTimes(1);
15401542

15411543
getHistory().push("/app-a/sub-routes-with-error/ok");

packages/runtime/src/internal/mediaQuery.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("mediaQuery", () => {
2626
});
2727
const newMedia = { breakpoint: nextBreakpoint };
2828
expect(getMedia()).toEqual(newMedia);
29-
expect(handler).lastCalledWith(
29+
expect(handler).toHaveBeenLastCalledWith(
3030
expect.objectContaining({
3131
detail: newMedia,
3232
})

packages/test-next/src/run.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22
import path from "node:path";
33
import { existsSync } from "node:fs";
4-
import jest from "jest";
4+
import { run } from "jest";
55
import { createJestConfig } from "./createJestConfig.js";
66

77
const packageDir = process.cwd();
@@ -23,4 +23,4 @@ args.push(
2323
)
2424
);
2525

26-
jest.run(args);
26+
run(args);

packages/utils/src/general/deepFreeze.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,41 @@ describe("deepFreeze", () => {
2626
expect(() => {
2727
// Add a new prop.
2828
(frozen as any).hello = "world";
29-
}).toThrowError();
29+
}).toThrow();
3030

3131
expect(() => {
3232
// Override an existed prop.
3333
frozen.string = "overridden";
34-
}).toThrowError();
34+
}).toThrow();
3535

3636
expect(() => {
3737
// Delete a prop.
3838
delete (frozen as Partial<typeof object>).string;
39-
}).toThrowError();
39+
}).toThrow();
4040

4141
expect(() => {
4242
// Push a item to a prop of array.
4343
frozen.array.push("z");
44-
}).toThrowError();
44+
}).toThrow();
4545

4646
expect(() => {
4747
// Pop a prop of array.
4848
frozen.array.pop();
49-
}).toThrowError();
49+
}).toThrow();
5050

5151
expect(() => {
5252
// Delete a prop of array.
5353
delete (frozen as Partial<typeof object>).array;
54-
}).toThrowError();
54+
}).toThrow();
5555

5656
expect(() => {
5757
// Override a nested object's prop.
5858
frozen.object.number = 2;
59-
}).toThrowError();
59+
}).toThrow();
6060

6161
expect(() => {
6262
// Override a nested object's prop.
6363
frozen.object.array.push(9);
64-
}).toThrowError();
64+
}).toThrow();
6565
});
6666
});

0 commit comments

Comments
 (0)