Set up Vitest and CI workflow for unit tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt Isenhower 2026-02-15 15:40:46 -08:00
parent 120f6e4dca
commit 7084b3c5ae
4 changed files with 1196 additions and 1297 deletions

23
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,23 @@
name: Tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm test

2454
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,8 @@
"preview": "vite preview --port 5050",
"lint": "eslint .",
"lint-fix": "npm run lint -- --fix",
"test": "vitest run",
"test:watch": "vitest",
"cron": "node app/index.mjs cron",
"start": "npm run sync:download && npm run splatnet:quick && npm run social && npm run cron",
"social": "node app/index.mjs social",
@ -65,6 +67,7 @@
"tailwindcss": "^4.1.18",
"typescript": "^5.9.3",
"vite": "^7.3.1",
"vitest": "^4.0.18",
"vue-eslint-parser": "^10.4.0"
}
}

13
vitest.config.mjs Normal file
View File

@ -0,0 +1,13 @@
import { fileURLToPath, URL } from 'url';
import { defineConfig } from 'vitest/config';
export default defineConfig({
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
test: {
include: ['app/**/*.test.mjs', 'src/**/*.test.{js,mjs}'],
},
});