mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
test: fix flaky E2E scenarios and stabilize test runner
This commit is contained in:
@@ -112,7 +112,10 @@ async function main() {
|
||||
}
|
||||
|
||||
for (const [index, suite] of suites.entries()) {
|
||||
const runEnvironment = suite.useDedicatedDatabase ? { DATABASE_URL: e2eDatabaseUrl, E2E_DATABASE_URL: e2eDatabaseUrl } : {};
|
||||
// E2E_DATABASE_URL is not in .env so pnpm's auto-loading cannot override it.
|
||||
// vitest.config.e2e.ts reads this and injects it as DATABASE_URL into all
|
||||
// test workers, ensuring NestJS never connects to the dev database.
|
||||
const runEnvironment = { E2E_DATABASE_URL: e2eDatabaseUrl };
|
||||
|
||||
if (suite.prepareDedicatedDatabase) {
|
||||
console.log(`Resetting and migrating dedicated e2e database for suite ${suite.id}...`);
|
||||
@@ -134,6 +137,8 @@ async function main() {
|
||||
"exec",
|
||||
"vitest",
|
||||
"run",
|
||||
"--config",
|
||||
"vitest.config.e2e.ts",
|
||||
suite.vitestTarget,
|
||||
"--reporter=default",
|
||||
"--reporter=junit",
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import path from 'path';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
const e2eDatabaseUrl =
|
||||
process.env.E2E_DATABASE_URL ?? 'postgres://projectx:projectx@localhost:5432/projectx_e2e';
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
tsconfigPaths: true,
|
||||
alias: {
|
||||
'@projectx/types': path.resolve(__dirname, '../packages/types/src/index.ts'),
|
||||
},
|
||||
},
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'node',
|
||||
pool: 'forks',
|
||||
include: ['test/**/*.e2e-spec.ts'],
|
||||
passWithNoTests: true,
|
||||
reporters: process.env.CI ? ['default', 'github-actions'] : ['default'],
|
||||
env: {
|
||||
DATABASE_URL: e2eDatabaseUrl,
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user