-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathvitest.config.ts
More file actions
57 lines (55 loc) · 3.26 KB
/
Copy pathvitest.config.ts
File metadata and controls
57 lines (55 loc) · 3.26 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
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { defineConfig } from 'vitest/config';
import path from 'path';
export default defineConfig({
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,
globals: true,
environment: 'node',
},
resolve: {
alias: [
// Subpath BEFORE the bare package: `@objectstack/core` is a PREFIX match with a
// FILE replacement, so without this entry it swallows the published `./logger`
// subpath and resolves it to `…/core/src/index.ts/logger` — ENOTDIR at run time.
// Pinned by the published-subpath rule in `scripts/check-test-source-alias.mjs`,
// which derives the population from `@objectstack/core`'s own `exports` map.
{ find: /^@objectstack\/core\/logger$/, replacement: path.resolve(__dirname, '../../core/src/logger.ts') },
{ find: '@objectstack/core', replacement: path.resolve(__dirname, '../../core/src/index.ts') },
{ find: '@objectstack/observability', replacement: path.resolve(__dirname, '../../observability/src/index.ts') },
// #9457: ONE anchored rule for every `@objectstack/spec` namespace, in place
// of the hand-maintained list of the subpaths this package's tests happened
// to reach. A string `find` matches by PREFIX, so with a FILE replacement the
// bare `@objectstack/spec` entry also swallowed every published namespace the
// list had not reached — `cloud`, `integration` and `studio` among them — and
// resolved it to `…/spec/src/index.ts/<ns>`: `ENOTDIR`, at run time, from a
// config that reads as correct, naming whichever module performed the import
// rather than this table.
//
// spec's export map is UNIFORM — every published namespace is
// `src/<ns>/index.ts`, with no FILE-shaped subpath of the kind
// `@objectstack/platform-objects/plugin` is — so one rule covers all of them
// and cannot go stale as tests reach new namespaces. Same shape as
// `packages/qa/downstream-contract` (PR #8129), `service-knowledge`,
// `service-settings` and `plugin-audit`; `packages/runtime` carries the pin
// over the rule (`src/spec-subpath-alias-coverage.pin.test.ts`).
//
// Kept from the enumeration because the reasons outlive it: `security` is
// reached transitively via `@objectstack/types` ([ADR-0105 D1] tenancy
// posture) and `shared` via `@objectstack/core`'s plural→singular fold
// (`pluralToSingular`, #7378). Neither is a reason to keep listing
// namespaces by hand.
{
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') },
],
},
});