-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathvitest.config.ts
More file actions
78 lines (76 loc) · 4.64 KB
/
Copy pathvitest.config.ts
File metadata and controls
78 lines (76 loc) · 4.64 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
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { defineConfig } from 'vitest/config';
import path from 'node:path';
export default defineConfig({
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') },
// #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 reason outlives it: `security` is
// reached transitively via `@objectstack/types` ([ADR-0105 D1] tenancy
// posture). That is not a reason to keep listing namespaces by hand.
//
// This package is also where the missing-subpath cost was first measured:
// `MetadataPlugin._parseAndRegisterArtifact` does `await import(
// '@objectstack/spec/cloud')`, which is why `packages/runtime`'s tests died
// with an `ENOTDIR` naming this plugin rather than their own alias table.
{
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') },
// [#16100] The deployment-ledger writer/reader pair the notification-event
// migration's receipt cases drive (`attestFreshDatastore` seeds the
// fresh-store row, `isDataMigrationVerified` reads the verdict back). The
// entry is ANCHORED on the subpath rather than spelled bare: this package
// publishes a FILE-shaped subpath (`./plugin`), so a bare prefix rule with
// a file replacement would resolve `…/system` to
// `…/platform-objects/src/index.ts/system` — ENOTDIR at run time, from a
// config that reads as correct.
{
find: /^@objectstack\/platform-objects\/system$/,
replacement: path.resolve(__dirname, '../platform-objects/src/system/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') },
],
},
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',
include: ['src/**/*.test.ts'],
},
});