-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathvitest.config.ts
More file actions
165 lines (162 loc) · 9.87 KB
/
Copy pathvitest.config.ts
File metadata and controls
165 lines (162 loc) · 9.87 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
// ── #13517: this suite asks the SchemaRegistry for quiet, DECLARATIVELY ─────
//
// Measured on THIS suite (one full `pnpm --filter @objectstack/runtime test`,
// `origin/main` b1b7d6088a): 6,730 lines on the run's stdout, 1,155 of them
// `[Registry] …`. 4,760 of the rest are the structured logger's `<ts> INFO …`
// lines, which do not go through `console` at all and are NOT what this key
// reaches (#13986).
//
// ⚠️ Read the share honestly, because this suite is NOT the dogfood one.
// Against the console-carried population (1,957 lines) `[Registry]` is 1,155 —
// **59%**, the largest single family but a long way from dogfood's 94.9%. The
// remaining ~800 are a mixed tail this key cannot reach: `[sql-driver] while
// creating/syncing table …` column reports, `[HonoServerPlugin] Server
// stopped`, `Paged read of … is NOT deterministic`, `[action-audit] …` and
// `[Protocol] DB hydration skipped …`. So the declaration below is worth its
// line here, and it is also not the whole story here — quieting the rest is a
// different question about those specific call sites, not a log level.
//
// `OS_REGISTRY_LOG` is `@objectstack/objectql`'s OWN published seam for that
// verbosity (`SchemaRegistryOptions.logLevel` / `REGISTRY_LOG_LEVELS`,
// registry.ts) — at `warn` the registry's private `log()` returns before
// writing. What it does NOT silence is the diagnostics: the ADR-0005
// `[Registry] Collision` lines go through a bare `console.warn` that the level
// never gates, so a real shadowing still speaks here.
//
// ⛔ Two things this deliberately is NOT. It does not move the engine's
// SHIPPED default (still `'info'` at objectql's registry.ts:1265, unchanged
// for every production reader), and it does not make library code sniff
// `process.env.VITEST` — a library that behaves differently under a test
// runner would make every log reading in tests a reading of something other
// than production. The request lives HERE, in the harness, where the test
// author can see it.
import { defineConfig } from 'vitest/config';
import path from 'node:path';
export default defineConfig({
resolve: {
// ARRAY form, not the object form: only the array form accepts a RegExp
// `find`, and the `@objectstack/platform-objects` entries below have to be
// anchored (see their note). The pre-existing string entries keep the
// prefix-match semantics they had as object keys — Vite normalizes an alias
// object into exactly this list, in this order, first match wins — so this
// conversion changes no resolution, it only makes room for a regex.
alias: [
// Subpath before the bare package: a string `find` prefix-replaces, so
// without this entry `@objectstack/core/logger` (imported by the built
// client, see route-ledger.conformance.test.ts) resolves to the garbage
// path `…/core/src/index.ts/logger`.
{ find: '@objectstack/core/logger', replacement: path.resolve(__dirname, '../core/src/logger.ts') },
{ find: '@objectstack/core', replacement: path.resolve(__dirname, '../core/src/index.ts') },
// #7828 / PR #8128: action-execution-destructive.test.ts reads the REAL
// `sys_*` identity declarations to prove that today's platform objects
// are excluded before `actionLooksDestructive` ever runs on them. That
// import resolved through `exports` to `platform-objects/dist` — a build
// artifact — so all 66 pins were a verdict about build state rather than
// about the declarations in the checkout (`pnpm check:test-source-alias`,
// #7668/#7778).
//
// ANCHORED regexes, array form, deliberately — the same correction
// `@objectstack/spec` gets in packages/qa/downstream-contract (PR #8129).
// A bare `@objectstack/platform-objects` string entry matches by PREFIX,
// so with a FILE replacement it also swallows the `/identity` subpath and
// resolves it to `…/platform-objects/src/index.ts/identity` — `ENOTDIR`,
// at run time, from a config that reads as correct.
//
// One rule for every namespace rather than an enumeration of the ones
// reached today, so it cannot go stale as tests reach new subpaths.
// `/plugin` is listed ahead of it because it is the one exported subpath
// that is a FILE (`src/plugin.ts`) and not a namespace directory: the
// namespace rule would send it to `src/plugin/index.ts`, which does not
// exist — and which `check:test-source-alias` cannot catch, since that
// path still reads as pointing at source.
{
find: /^@objectstack\/platform-objects\/plugin$/,
replacement: path.resolve(__dirname, '../platform-objects/src/plugin.ts'),
},
{
find: /^@objectstack\/platform-objects\/([a-z-]+)$/,
replacement: path.join(path.resolve(__dirname, '..'), 'platform-objects/src/$1/index.ts'),
},
{
find: /^@objectstack\/platform-objects$/,
replacement: path.resolve(__dirname, '../platform-objects/src/index.ts'),
},
{ find: '@objectstack/rest', replacement: path.resolve(__dirname, '../rest/src/index.ts') },
// #9457: ONE anchored rule for every `@objectstack/spec` namespace, in
// place of the hand-maintained list of the twelve subpaths tests happened
// to reach on the day it was written. That list had gone stale in three
// places — `cloud`, `integration` and `studio` are published subpath
// exports with no entry — and a bare string `find` matches by PREFIX with
// a FILE replacement, so `@objectstack/spec/cloud` resolved to the
// garbage path `…/spec/src/index.ts/cloud` and died with `ENOTDIR` inside
// whichever module happened to import it. Measured before this change:
// `MetadataPlugin._parseAndRegisterArtifact` (`await
// import('@objectstack/spec/cloud')`) took every artifact-loading test in
// this package down with an error naming the metadata plugin rather than
// this table — the diagnostic distance is the real defect, the missing
// subpath is only its trigger.
//
// `@objectstack/spec`'s export map is UNIFORM: every published namespace
// is `src/<ns>/index.ts`, and it has no FILE-shaped subpath of the kind
// `@objectstack/platform-objects/plugin` is (which is exactly why the
// rule above it needs a hand-written entry and this one does not). So one
// rule covers all fifteen and cannot go stale as tests reach new
// namespaces — the same shape `packages/qa/downstream-contract` (PR
// #8129), `service-knowledge`, `service-settings` and `plugin-audit`
// already carry.
//
// What the enumeration recorded, kept because the reasons outlive it:
// `automation` carries the declared effect `AppPlugin` reads off a bundle
// function (#4396); `identity` is reached through
// `@objectstack/platform-objects` (`sys-user.object.ts`) by
// notifications.hono.integration.test.ts; `security` is reached
// transitively via `@objectstack/types` ([ADR-0105 D1] tenancy posture).
// None of the three is a reason to keep listing namespaces by hand.
//
// `src/spec-subpath-alias-coverage.pin.test.ts` pins the RULE rather than
// any one subpath: it derives the population from spec's published
// `exports` map, so a subpath this rule stops covering fails there.
{
find: /^@objectstack\/spec\/([a-z-]+)$/,
replacement: path.join(path.resolve(__dirname, '..'), 'spec/src/$1/index.ts'),
},
{ find: /^@objectstack\/spec$/, replacement: path.resolve(__dirname, '../spec/src/index.ts') },
// Subpath BEFORE the bare package, same prefix-match reason: `./node` is a
// published subpath served by a FILE (`types/src/node.ts` — the node-only slice
// the root export deliberately excludes), so the bare entry would resolve it to
// `…/types/src/index.ts/node`. Same published-subpath rule pins it.
{ find: /^@objectstack\/types\/node$/, replacement: path.resolve(__dirname, '../types/src/node.ts') },
{ find: '@objectstack/types', replacement: path.resolve(__dirname, '../types/src/index.ts') },
// Dev-only: app-plugin.jobs.test.ts drives the REAL CronJobAdapter, so
// the #4567 regression (croner rejecting the expression envelope) is
// reproduced by the actual scheduler rather than by a double.
{ find: '@objectstack/service-job', replacement: path.resolve(__dirname, '../services/service-job/src/index.ts') },
// Dev-only: app-plugin.disabled-seed.test.ts drives the REAL
// `sys_packages` → registry rehydration (#5047), so the empty-env seed
// regression is proven against the actual hydration code rather than a
// re-implementation of it.
{
find: '@objectstack/service-package',
replacement: path.resolve(__dirname, '../services/service-package/src/index.ts'),
},
],
},
test: {
// A late console.* must not redden a green suite (#10374): vitest's worker
// forwards console output over RPC and discards the promise, and a write
// landing after teardown's rpcDone() snapshot is rejected into an unhandled
// error — a fully green run that exits 1. Disarming removes the mechanism.
// Mechanism + measured costs: examples/app-showcase/vitest.config.ts.
// Enforced repo-wide by scripts/check-console-intercept-disarm.mjs.
disableConsoleIntercept: true,
// #13517: quiet the registry's per-item registration chatter — the
// engine's own `OS_REGISTRY_LOG` seam, not a change to its shipped
// default. Header docblock carries the measurement and the rationale,
// including the tail this key does NOT reach in this package.
env: { OS_REGISTRY_LOG: 'warn' },
globals: true,
environment: 'node',
include: ['src/**/*.test.ts'],
},
});