feat: Add testing infrastructure and documentation
- 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>
This commit is contained in:
34
tests/setup.js
Normal file
34
tests/setup.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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 = '';
|
||||
});
|
||||
Reference in New Issue
Block a user