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:
Generated
+188
-1098
File diff suppressed because it is too large
Load Diff
@@ -13,11 +13,11 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/vite-plugin-svelte": "^6.2.0",
|
"@sveltejs/vite-plugin-svelte": "^6.2.0",
|
||||||
"@testing-library/svelte": "^5.2.3",
|
"@testing-library/svelte": "^5.2.3",
|
||||||
"@vitest/coverage-v8": "^2.1.8",
|
"@vitest/coverage-v8": "^3.2.4",
|
||||||
"jsdom": "^25.0.1",
|
"jsdom": "^25.0.1",
|
||||||
"svelte": "^5.0.0",
|
"svelte": "^5.0.0",
|
||||||
"vite": "^6.3.0",
|
"vite": "^6.3.0",
|
||||||
"vitest": "^2.1.8",
|
"vitest": "^3.2.4",
|
||||||
"tailwindcss": "^4.0.0",
|
"tailwindcss": "^4.0.0",
|
||||||
"@tailwindcss/vite": "^4.0.0"
|
"@tailwindcss/vite": "^4.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ describe('Login Component', () => {
|
|||||||
it('should have login button', () => {
|
it('should have login button', () => {
|
||||||
render(Login);
|
render(Login);
|
||||||
|
|
||||||
const loginButton = screen.getByRole('button', { name: /login/i }) ||
|
const loginButton = screen.getByRole('button', { name: /sign in/i }) ||
|
||||||
screen.getByText(/login/i);
|
screen.getByText(/sign in/i);
|
||||||
expect(loginButton).toBeTruthy();
|
expect(loginButton).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,21 @@ global.MutationObserver = vi.fn(() => ({
|
|||||||
takeRecords: 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
|
// Mock fetch
|
||||||
global.fetch = vi.fn();
|
global.fetch = vi.fn();
|
||||||
|
|
||||||
|
|||||||
@@ -373,6 +373,7 @@ describe('API Client - Error Handling', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle network errors', async () => {
|
it('should handle network errors', async () => {
|
||||||
|
global.fetch.mockReset();
|
||||||
global.fetch.mockRejectedValueOnce(new Error('Network error'));
|
global.fetch.mockRejectedValueOnce(new Error('Network error'));
|
||||||
|
|
||||||
await expect(get('/test/endpoint')).rejects.toThrow('Network error');
|
await expect(get('/test/endpoint')).rejects.toThrow('Network error');
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export default defineConfig({
|
|||||||
globals: true,
|
globals: true,
|
||||||
environment: 'jsdom',
|
environment: 'jsdom',
|
||||||
setupFiles: ['./tests/setup.js'],
|
setupFiles: ['./tests/setup.js'],
|
||||||
|
resetMocks: true,
|
||||||
coverage: {
|
coverage: {
|
||||||
provider: 'v8',
|
provider: 'v8',
|
||||||
reporter: ['text', 'html', 'lcov'],
|
reporter: ['text', 'html', 'lcov'],
|
||||||
@@ -23,6 +24,7 @@ export default defineConfig({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
|
conditions: ['browser'],
|
||||||
alias: {
|
alias: {
|
||||||
'@': '/src'
|
'@': '/src'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user