test(frontend): add dom fixture helpers

This commit is contained in:
pixelpaws
2025-09-24 15:39:52 +08:00
parent 59d027181d
commit f51f354e48
7 changed files with 129 additions and 10 deletions

View File

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