fix: upgrade vitest to v3, compat fixes for Svelte 5 + jsdom
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -28,8 +28,8 @@ describe('Login Component', () => {
|
||||
it('should have login button', () => {
|
||||
render(Login);
|
||||
|
||||
const loginButton = screen.getByRole('button', { name: /login/i }) ||
|
||||
screen.getByText(/login/i);
|
||||
const loginButton = screen.getByRole('button', { name: /sign in/i }) ||
|
||||
screen.getByText(/sign in/i);
|
||||
expect(loginButton).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@@ -75,6 +75,21 @@ global.MutationObserver = vi.fn(() => ({
|
||||
takeRecords: vi.fn(() => [])
|
||||
}));
|
||||
|
||||
// Mock Element.animate (used by Svelte transitions, not implemented in jsdom)
|
||||
Element.prototype.animate = vi.fn(() => ({
|
||||
finished: Promise.resolve(),
|
||||
cancel: vi.fn(),
|
||||
pause: vi.fn(),
|
||||
play: vi.fn(),
|
||||
reverse: vi.fn(),
|
||||
finish: vi.fn(),
|
||||
commitStyles: vi.fn(),
|
||||
persist: vi.fn(),
|
||||
addEventListener: vi.fn(),
|
||||
removeEventListener: vi.fn(),
|
||||
dispatchEvent: vi.fn(),
|
||||
}));
|
||||
|
||||
// Mock fetch
|
||||
global.fetch = vi.fn();
|
||||
|
||||
|
||||
@@ -373,6 +373,7 @@ describe('API Client - Error Handling', () => {
|
||||
});
|
||||
|
||||
it('should handle network errors', async () => {
|
||||
global.fetch.mockReset();
|
||||
global.fetch.mockRejectedValueOnce(new Error('Network error'));
|
||||
|
||||
await expect(get('/test/endpoint')).rejects.toThrow('Network error');
|
||||
|
||||
Reference in New Issue
Block a user