feat(tests): add frontend automated testing setup with Vitest and jsdom

This commit is contained in:
Will Miao
2025-09-23 23:05:55 +08:00
parent dde7cf71c6
commit ae145de2f2
7 changed files with 2697 additions and 0 deletions

16
tests/frontend/setup.js Normal file
View File

@@ -0,0 +1,16 @@
import { afterEach, beforeEach } from 'vitest';
beforeEach(() => {
// Ensure storage is clean before each test to avoid cross-test pollution
localStorage.clear();
sessionStorage.clear();
// Reset DOM state for modules that rely on body attributes
document.body.innerHTML = '';
document.body.dataset.page = '';
});
afterEach(() => {
// Clean any dynamically attached globals by tests
delete document.body.dataset.page;
});