Repository navigation
Expand file tree
/
Copy pathvitest.config.ts
More file actions
64 lines (62 loc) 路 2.71 KB
/
Copy pathvitest.config.ts
File metadata and controls
64 lines (62 loc) 路 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { configDefaults, defineConfig } from 'vitest/config';
/** The PostgreSQL projects' global setup: their Prisma client, and the sweep of stale `whk_` databases. */
const postgresSetup = ['tests/support/generate-prisma-client.ts', 'tests/support/global-setup.ts'];
export default defineConfig({
// Legacy decorators with emitted metadata, as in the nestjs/nest monorepo, so
// parameter decorators and DI type lookup work in the specs. Class fields declared
// without an initializer are types only, as under `tsc` with `useDefineForClassFields: false`.
oxc: {
decorator: {
legacy: true,
emitDecoratorMetadata: true,
},
assumptions: { setPublicClassFields: true },
typescript: { removeClassFieldsWithoutInitializer: true },
},
test: {
globals: true,
setupFiles: ['reflect-metadata'],
// tests/postgres/ is PostgresWebhookStore's own project (@nestjs/webhooks/postgres): its contracts through every
// executor on PostgreSQL (SQL_TEST_PG_URL, else a throwaway cluster from local binaries, else skipped with the
// reason) and on PGlite, its migrations and command, and the module on it. `--project webhooks:postgres-store`
// runs it alone. tests/mysql/ is MySqlWebhookStore's (@nestjs/webhooks/mysql), on the MySQL of SQL_TEST_MYSQL_URL,
// else skipped with the reason: `--project webhooks:mysql-store`. Each project's global setup generates only its
// own Prisma client, so no two write the same files.
projects: [
{
extends: true,
test: {
name: 'webhooks',
include: ['tests/**/*.spec.ts'],
exclude: [...configDefaults.exclude, 'tests/postgres/**', 'tests/mysql/**'],
globalSetup: postgresSetup,
},
},
{
extends: true,
test: {
name: 'webhooks:postgres-store',
include: ['tests/postgres/**/*.spec.ts'],
testTimeout: 30_000,
hookTimeout: 30_000,
globalSetup: postgresSetup,
},
},
{
extends: true,
test: {
name: 'webhooks:mysql-store',
include: ['tests/mysql/**/*.spec.ts'],
testTimeout: 30_000,
hookTimeout: 30_000,
// The MySQL server may be shared (here, the nest repo's integration MySQL): at most 4 files at once, each with
// at most 5 connections, after the other projects' files (vitest runs a project with another worker count in
// a group of its own). Its stale `whk_` databases are swept before and after the run.
globalSetup: ['tests/support/generate-prisma-mysql-client.ts', 'tests/support/mysql-global-setup.ts'],
maxWorkers: 4,
sequence: { groupOrder: 1 },
},
},
],
},
});