Files
OpenFrame/vitest.config.ts
T
yusufipk 72159377fb fix(ci): make the suites run under node, and start MinIO as a step
Both failures were environment-specific and invisible locally.

The vitest projects only ever ran under bun here, because the containers
used for local runs have no node at all. On a GitHub runner the vitest
bin's `#!/usr/bin/env node` shebang wins, and node's ESM resolver cannot
resolve the extensionless 'next/server' that next-auth/lib/env.js
imports, so all 17 api suites died with ERR_MODULE_NOT_FOUND. The
next-auth inline rule that the unit project already carried is now
declared at the root so every project inherits it. All three projects
verified under node as well as bun.

The e2e job could never start: a GitHub Actions `services:` block cannot
pass a command to its container, and the MinIO entrypoint requires
`server /data`, so the container printed its usage text and exited.
MinIO now starts as a step with `docker run`, which means the job can no
longer run inside a container, which in turn removes the reason the
Playwright image was needed at all. The browser is installed on the
runner instead, so the image tag no longer has to be kept in lockstep
with the npm package.
2026-07-26 11:28:56 +07:00

57 lines
1.8 KiB
TypeScript

import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
export default defineConfig({
plugins: [tsconfigPaths()],
test: {
server: {
deps: {
// Anything reaching lib/auth.ts pulls in next-auth, whose lib/env.js imports
// the extensionless specifier 'next/server'. Node's ESM resolver cannot
// resolve that, so the module has to go through Vite's resolver instead of
// being externalised. Bun resolves it either way, which is why this is easy
// to miss: the containers used locally have no node at all, so vitest runs
// under bun there, while on a GitHub runner the vitest bin's
// `#!/usr/bin/env node` shebang wins and every suite that touches auth dies
// with ERR_MODULE_NOT_FOUND. Declared at the root so all three projects
// inherit it through `extends: true`.
inline: [/next-auth/],
},
},
projects: [
{
extends: true,
test: {
name: 'unit',
environment: 'node',
include: ['tests/unit/**/*.test.ts'],
},
},
{
extends: true,
test: {
name: 'api',
environment: 'node',
include: ['tests/api/**/*.test.ts'],
setupFiles: ['tests/setup/api.ts'],
globalSetup: ['tests/setup/db-global.ts'],
// One shared test database; parallel files would fight over TRUNCATE.
fileParallelism: false,
testTimeout: 20_000,
},
},
{
extends: true,
plugins: [tsconfigPaths(), react()],
test: {
name: 'component',
environment: 'jsdom',
include: ['tests/component/**/*.test.{ts,tsx}'],
setupFiles: ['tests/setup/component.ts'],
},
},
],
},
});