fix(tests): add missing Sentry mock event fields across 14 spec files; fix test:coverage semicolon
`@sentry/sveltekit` wraps load functions and reads `event.request.method` and `event.url.pathname`. Mock events that omitted `request` or `url` threw `TypeError: Cannot read properties of undefined` on every invocation, silently masking 86 test failures on main. Two root causes fixed: - Added `request: new Request(...)` (and `url: new URL(...)` where absent) to all mock event objects in 14 `*.server.spec.ts` files - Changed `;` to `&&` in the `test:coverage` npm script so a failing server run propagates its exit code instead of being swallowed by the client run All 576 server-project tests now pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,11 @@ describe('admin/ocr/global — load', () => {
|
||||
data: { runs: [{ id: 'run1' }], personNames: {} }
|
||||
});
|
||||
|
||||
const result = (await load({ fetch } as never))!;
|
||||
const result = (await load({
|
||||
fetch,
|
||||
request: new Request('http://localhost/admin/ocr/global'),
|
||||
url: new URL('http://localhost/admin/ocr/global')
|
||||
} as never))!;
|
||||
|
||||
expect(result.history.runs).toHaveLength(1);
|
||||
});
|
||||
@@ -22,6 +26,12 @@ describe('admin/ocr/global — load', () => {
|
||||
it('throws error when API call fails', async () => {
|
||||
mockApi.GET.mockResolvedValue({ response: { ok: false, status: 500 }, error: {} });
|
||||
|
||||
await expect(load({ fetch } as never)).rejects.toMatchObject({ status: 500 });
|
||||
await expect(
|
||||
load({
|
||||
fetch,
|
||||
request: new Request('http://localhost/admin/ocr/global'),
|
||||
url: new URL('http://localhost/admin/ocr/global')
|
||||
} as never)
|
||||
).rejects.toMatchObject({ status: 500 });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user