Add vitest 4.1, jsdom 25, and @testing-library/preact as devDeps so the widget gets a real test surface for the upcoming Shadow DOM mount work. - vitest.config.ts mirrors the build aliases (preact/compat) and uses jsdom for DOM-touching tests. - tests/setup.ts is the place to add polyfills as the surface grows. - tests/unit/smoke.test.ts confirms vitest runs, jsdom is wired, and Shadow DOM API is available. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
22 lines
611 B
TypeScript
22 lines
611 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
|
|
describe('Vitest infrastructure', () => {
|
|
it('runs assertions', () => {
|
|
expect(1 + 1).toBe(2);
|
|
});
|
|
|
|
it('exposes the jsdom document', () => {
|
|
const div = document.createElement('div');
|
|
div.id = 'sanity';
|
|
document.body.appendChild(div);
|
|
expect(document.getElementById('sanity')).toBe(div);
|
|
});
|
|
|
|
it('supports Shadow DOM API in jsdom', () => {
|
|
const host = document.createElement('div');
|
|
document.body.appendChild(host);
|
|
const shadow = host.attachShadow({ mode: 'open' });
|
|
expect(host.shadowRoot).toBe(shadow);
|
|
});
|
|
});
|