Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@
"typescript54": "npm:typescript@5.4",
"typescript55": "npm:typescript@5.5",
"vite": "^6.0.11",
"vitest": "^3.0.4"
"vitest": "^4.0.14"
}
}
2 changes: 1 addition & 1 deletion packages/cli-testing-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"peerDependencies": {
"@jest/expect": "^29.0.0",
"@jest/globals": "^29.0.0",
"vitest": "^3.0.0"
"vitest": "^3.0.0 || ^4.0.0"
},
"peerDependenciesMeta": {
"@jest/globals": {
Expand Down
20 changes: 14 additions & 6 deletions packages/cli-testing-library/tests/get-user-code-frame.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ test("it returns only user code frame when code frames from node_modules are fir
at Object.<anonymous> (/sample-error/node_modules/@es2050/console/build/index.js:4:10)
${userStackFrame}
`;
globalErrorMock.mockImplementationOnce(() => ({ stack }));
globalErrorMock.mockImplementationOnce(function () {
return { stack };
});
const userTrace = getUserCodeFrame();

expect(userTrace).toMatchInlineSnapshot(`
Expand All @@ -62,7 +64,9 @@ test("it returns only user code frame when node code frames are present afterwar
at Object.<anonymous> (/sample-error/error-example.js:14:1)
at internal/main/run_main_module.js:17:47
`;
globalErrorMock.mockImplementationOnce(() => ({ stack }));
globalErrorMock.mockImplementationOnce(function () {
return { stack };
});
const userTrace = getUserCodeFrame();

expect(userTrace).toMatchInlineSnapshot(`
Expand All @@ -76,13 +80,17 @@ test("it returns only user code frame when node code frames are present afterwar
});

test("it returns empty string if file from code frame can't be read", () => {
(fs.readFileSync as ReturnType<typeof vi.fn>).mockImplementationOnce(() => {
throw Error();
});
(fs.readFileSync as ReturnType<typeof vi.fn>).mockImplementationOnce(
function () {
throw Error();
},
);
const stack = `Error: Kaboom
${userStackFrame}
`;
globalErrorMock.mockImplementationOnce(() => ({ stack }));
globalErrorMock.mockImplementationOnce(function () {
return { stack };
});

expect(getUserCodeFrame()).toEqual("");
});
Loading