This repository is a example how to create avite
app withpreact
.
Following packages are mainly used:
- vite
- preact
- typescript
- eslint
- prettier
Testing packages:
- vitest
- @testing-library/preact
- happy-dom
- vitest-dom
Install the dependencies with your package manager of choice. This example will use pnpm
as the package manager.
pnpm install
pnpm dev
pnpm test
Check out the app.test.tsx file.
Check out the vite.config.ts file.
Here is an example how it can look like with happy-dom
:
/// <reference types="vitest" />
import preact from '@preact/preset-vite';
import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig({
define: {
'import.meta.vitest': 'undefined',
},
plugins: [preact()],
test: {
globals: true,
environment: 'happy-dom',
setupFiles: ['./src/test-setup.ts'],
includeSource: ['src/**/*.{ts,tsx}'],
mockReset: true,
restoreMocks: true,
},
});
More information at https://vitest.dev/guide/#configuring-vitest.