mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-17 22:00:40 -07:00
Two projects in one root config: 'unit' (happy-dom) for stores, hooks, and utils, and 'browser' (real Chromium via the playwright provider) for component tests — no jsdom polyfills for EventSource, AudioContext, or canvas. Harness pieces: createMockPlatform (spy-able Platform with an updater emit handle), renderWithProviders (fresh QueryClient with polling disabled + PlatformProvider), MSW worker with baseline health handler, and a store-reset teardown covering all eight zustand stores. Seed tests cover uiStore theme, serverStore invalidation, and an AboutPage render in Chromium. Requires node >= 20 (.node-version added); run with bun run test.
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import path from 'node:path';
|
|
import react from '@vitejs/plugin-react';
|
|
import { playwright } from '@vitest/browser-playwright';
|
|
import { defineConfig } from 'vitest/config';
|
|
import { changelogPlugin } from './app/plugins/changelog';
|
|
|
|
const appSrc = path.resolve(__dirname, 'app/src');
|
|
|
|
const shared = {
|
|
plugins: [react(), changelogPlugin(__dirname)],
|
|
resolve: {
|
|
alias: { '@': appSrc },
|
|
},
|
|
};
|
|
|
|
export default defineConfig({
|
|
...shared,
|
|
test: {
|
|
projects: [
|
|
{
|
|
...shared,
|
|
test: {
|
|
name: 'unit',
|
|
environment: 'happy-dom',
|
|
include: ['app/src/**/*.test.{ts,tsx}'],
|
|
exclude: ['app/src/**/*.browser.test.{ts,tsx}'],
|
|
setupFiles: ['app/src/test/setup.ts'],
|
|
},
|
|
},
|
|
{
|
|
...shared,
|
|
publicDir: path.resolve(__dirname, 'app/src/test/public'),
|
|
test: {
|
|
name: 'browser',
|
|
include: ['app/src/**/*.browser.test.{ts,tsx}'],
|
|
setupFiles: ['app/src/test/setup.ts', 'app/src/test/setup.browser.ts'],
|
|
browser: {
|
|
enabled: true,
|
|
headless: true,
|
|
provider: playwright(),
|
|
instances: [{ browser: 'chromium' }],
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|