chore: add test config and instructions

This commit is contained in:
ayo 2026-06-02 13:49:00 +02:00
parent 4860085aef
commit f2bbfbf1b4
2 changed files with 38 additions and 7 deletions

View file

@ -23,13 +23,30 @@ $ pnpm i
## Commands ## Commands
| Command | Action | | Command | Action |
| ------------------- | ---------------------------------------------- | | ----------------------------- | ---------------------------------------------- |
| `pnpm run dev` | start dev server | | `pnpm run dev` | start dev server |
| `pnpm run build` | generate static files to `dist` directory | | `pnpm run build` | generate static files to `dist` directory |
| `pnpm run deploy` | upload to my server | | `pnpm run deploy` | upload to my server |
| `pnpm run prep:now` | back up and clear current `now page` constants | | `pnpm run prep:now` | back up and clear current `now page` constants |
| `pnpm run patch:build:deploy` | increment version, build, then upload | | `pnpm run patch:build:deploy` | increment version, build, then upload |
## Testing
This project uses Vitest for unit tests. The test script is defined in `package.json` as `vitest run .`.
Run tests locally with pnpm (recommended):
```bash
# install dependencies (if you haven't already)
pnpm i
# run tests once
pnpm test
# run Vitest in interactive/watch mode
pnpm exec vitest
```
## Deployment ## Deployment
For the script `npm run deploy`, you need to add an environmental variable named HOST containing the IP address of the host server. This will scp the build files into the server. For the script `npm run deploy`, you need to add an environmental variable named HOST containing the IP address of the host server. This will scp the build files into the server.

14
vitest.config.ts Normal file
View file

@ -0,0 +1,14 @@
import { defineConfig } from 'vitest/config'
// Exclude generated files and heavy folders from the watcher to avoid
// continuous re-runs when build output or other tools touch files.
export default defineConfig({
test: {
globals: true,
environment: 'node',
exclude: ['dist/**', 'public/**', 'node_modules/**'],
},
watch: {
exclude: ['dist/**', 'public/**', 'node_modules/**', '.git/**'],
},
})