test: split vitest into node + nuxt projects and add a Postgres harness
Component/runtime specs (*.nuxt.spec.ts) run in the Nuxt environment; all other specs run in a plain node environment where node_modules stay external, so native CJS deps like `pg` load correctly (the Nuxt runtime inlines them and breaks pg's internal `class … extends Pool`). Adds tests/helpers/db.ts, which spins up and migrates a dedicated test database for repository integration tests, and renames the board spec to the .nuxt suffix.
This commit is contained in:
@@ -1,9 +1,30 @@
|
||||
import { defineConfig } from 'vitest/config'
|
||||
import { defineVitestConfig } from '@nuxt/test-utils/config'
|
||||
|
||||
export default defineVitestConfig({
|
||||
// Two projects, split by filename:
|
||||
// • *.nuxt.spec.ts → run in the Nuxt runtime (components, anything needing
|
||||
// auto-imports or the app environment).
|
||||
// • everything else → a plain node environment. node_modules stay external,
|
||||
// so native CJS deps like `pg` load correctly (the Nuxt runtime inlines them
|
||||
// and breaks pg's internal `class … extends Pool`).
|
||||
export default defineConfig({
|
||||
test: {
|
||||
// Default to a plain node environment; component/integration specs opt into
|
||||
// the Nuxt runtime per-file with `// @vitest-environment nuxt`.
|
||||
environment: 'node',
|
||||
projects: [
|
||||
{
|
||||
test: {
|
||||
name: 'server',
|
||||
environment: 'node',
|
||||
include: ['tests/**/*.spec.ts'],
|
||||
exclude: ['tests/**/*.nuxt.spec.ts'],
|
||||
},
|
||||
},
|
||||
defineVitestConfig({
|
||||
test: {
|
||||
name: 'nuxt',
|
||||
environment: 'nuxt',
|
||||
include: ['tests/**/*.nuxt.spec.ts'],
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user