assert console availability directly instead of matching an error message

This commit is contained in:
Horizontal42 2026-08-09 15:57:33 +03:00 • committed by GitHub
parent 5554205193
commit 62ef8cc8cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -130,13 +130,10 @@ describe("extensions", () => {
it("has no host globals inside the sandbox", async () => { it("has no host globals inside the sandbox", async () => {
await runExtensions(mockEngine as SumEngine, [ await runExtensions(mockEngine as SumEngine, [
{ name: "probe", code: "if (typeof window !== 'undefined' || typeof fetch !== 'undefined') throw new Error('leak');" }, { name: "probe", code: "if (typeof window !== 'undefined' || typeof fetch !== 'undefined' || typeof console !== 'undefined') throw new Error('leak');" },
{ name: "log", code: "console.log('hi');" },
]); ]);
expect(consoleErrorSpy).toHaveBeenCalledTimes(1); expect(consoleErrorSpy).not.toHaveBeenCalled();
expect(consoleErrorSpy.mock.calls[0][0]).toBe("extension log failed:");
expect(consoleErrorSpy.mock.calls[0][1].message).toMatch(/console/);
}); });
it("interrupts an infinite loop at load time", async () => { it("interrupts an infinite loop at load time", async () => {