- Set up Vitest for unit testing with jsdom - Add test setup with Web Audio API and requestAnimationFrame mocks - Create initial test suites for DOM and animations modules - Add test scripts to package.json (test, test:ui, test:run, coverage) - Update CI workflow to include test execution - Create CONTRIBUTING.md with conventional commits guidelines - Create SECURITY.md with security policy - Update ESLint config to support test files - All tests passing (8/8) Co-authored-by: ZaneThePython <102631678+ZaneThePython@users.noreply.github.com>
35 lines
837 B
JavaScript
35 lines
837 B
JavaScript
// Test setup file
|
|
import { beforeEach, vi } from 'vitest';
|
|
|
|
// Mock Web Audio API
|
|
global.AudioContext = vi.fn().mockImplementation(() => ({
|
|
createOscillator: vi.fn().mockReturnValue({
|
|
connect: vi.fn(),
|
|
frequency: {
|
|
setValueAtTime: vi.fn(),
|
|
exponentialRampToValueAtTime: vi.fn(),
|
|
},
|
|
start: vi.fn(),
|
|
stop: vi.fn(),
|
|
}),
|
|
createGain: vi.fn().mockReturnValue({
|
|
connect: vi.fn(),
|
|
gain: {
|
|
setValueAtTime: vi.fn(),
|
|
exponentialRampToValueAtTime: vi.fn(),
|
|
},
|
|
}),
|
|
destination: {},
|
|
currentTime: 0,
|
|
}));
|
|
|
|
// Mock requestAnimationFrame
|
|
global.requestAnimationFrame = vi.fn((callback) => setTimeout(callback, 16));
|
|
global.cancelAnimationFrame = vi.fn(clearTimeout);
|
|
|
|
// Reset DOM before each test
|
|
beforeEach(() => {
|
|
document.body.innerHTML = '';
|
|
document.head.innerHTML = '';
|
|
});
|