generated from coulomb/repo-seed
add: comprehensive TDD test infrastructure
- Add Vitest + jsdom testing framework - Create unit tests for engine.js and generator.js - Add integration tests for end-to-end workflows - Include test utilities and setup helpers - Document testing approach in TESTING.md - Document all dependencies in DEPENDS.md - Add Makefile with test targets and dev workflow 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
39
test/setup.js
Normal file
39
test/setup.js
Normal file
@@ -0,0 +1,39 @@
|
||||
// Test setup file for Vitest
|
||||
import { vi } from 'vitest'
|
||||
|
||||
// Mock PapaParse (since it's loaded via CDN)
|
||||
global.Papa = {
|
||||
parse: vi.fn()
|
||||
}
|
||||
|
||||
// Mock fetch for loading files
|
||||
global.fetch = vi.fn()
|
||||
|
||||
// Setup DOM helpers
|
||||
beforeEach(() => {
|
||||
// Reset DOM
|
||||
document.head.innerHTML = ''
|
||||
document.body.innerHTML = ''
|
||||
|
||||
// Clear all mocks
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
// Create helper functions for DOM setup
|
||||
export const createMockElement = (tagName, attributes = {}) => {
|
||||
const element = document.createElement(tagName)
|
||||
Object.entries(attributes).forEach(([key, value]) => {
|
||||
element.setAttribute(key, value)
|
||||
})
|
||||
return element
|
||||
}
|
||||
|
||||
export const setupBasicDOM = () => {
|
||||
document.body.innerHTML = `
|
||||
<div id="projectName"></div>
|
||||
<div id="projectSubtitle"></div>
|
||||
<div id="viewer"></div>
|
||||
<link id="dynamicCss" rel="stylesheet" href="">
|
||||
<button id="downloadSvg"></button>
|
||||
`
|
||||
}
|
||||
Reference in New Issue
Block a user