|
| 1 | +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. |
| 2 | + |
| 3 | +/** |
| 4 | + * This package had NO vitest config until #10371, and that is the fact this |
| 5 | + * header exists to keep visible: adding one changes how every test file in |
| 6 | + * `packages/connectors/connector-openapi` is configured, not just the file that |
| 7 | + * needed it. So it is deliberately minimal — anchored `resolve.alias` entries |
| 8 | + * and **no `test` block at all**, because the package's existing test files run |
| 9 | + * on vitest's defaults (`globals: false`, `environment: 'node'`) and import |
| 10 | + * `describe`/`it`/`expect` explicitly. Sibling configs in this repo do carry |
| 11 | + * `test: { globals: true, … }`; copying that shape here would silently |
| 12 | + * re-specify the defaults for every existing file. |
| 13 | + * |
| 14 | + * ## Why the two entries |
| 15 | + * |
| 16 | + * `plugin-shutdown-unregisters-connector.test.ts` (#10371) boots a REAL |
| 17 | + * `LiteKernel` with the REAL `AutomationServicePlugin` to prove that |
| 18 | + * `kernel.shutdown()` reaches `ConnectorOpenApiPlugin.destroy()` — the whole |
| 19 | + * point of that card is that the kernel calls `destroy()` and never called |
| 20 | + * `stop()`, so a stand-in kernel would assert nothing. Without these entries |
| 21 | + * both imports resolve through their packages' `exports` to **dist**, which |
| 22 | + * makes the test a verdict about build state rather than about the source in |
| 23 | + * the checkout — and the dangerous half of that is not a loud error but a test |
| 24 | + * that passes GREEN against a stale artifact with nothing in the output saying |
| 25 | + * so. `scripts/check-test-source-alias.mjs` carries the measured history |
| 26 | + * (#7668, #7778, #7849); it named these two imports and is the gate that fails |
| 27 | + * without the entries below. |
| 28 | + * |
| 29 | + * ⚠️ The registry in that script is SHRINK-ONLY, so widening |
| 30 | + * `KNOWN_UNALIASED_TEST_IMPORTS['@objectstack/connector-openapi']` was never an |
| 31 | + * option, and it is deliberately left untouched: its one remaining member, |
| 32 | + * `@objectstack/spec`, is still reached unaliased by this package's other test |
| 33 | + * files and stays that registry's problem to retire. Aliasing bare |
| 34 | + * `@objectstack/spec` here would additionally hit rule 5's ENOTDIR trap (its |
| 35 | + * subpaths would resolve through `…/spec/src/index.ts/<sub>`), which is why |
| 36 | + * only the two specifiers the gate actually named are added. |
| 37 | + */ |
| 38 | + |
| 39 | +import { defineConfig } from 'vitest/config'; |
| 40 | +import path from 'path'; |
| 41 | + |
| 42 | +export default defineConfig({ |
| 43 | + resolve: { |
| 44 | + // Array form with ANCHORED patterns, per the trap the gate documents: the |
| 45 | + // object form matches by PREFIX, so a bare key whose replacement is a FILE |
| 46 | + // also swallows every subpath and resolves it to `…/index.ts/<sub>` |
| 47 | + // (`ENOTDIR`, at run time, in a config that looks right). |
| 48 | + alias: [ |
| 49 | + { |
| 50 | + find: /^@objectstack\/core$/, |
| 51 | + replacement: path.resolve(__dirname, '../../core/src/index.ts'), |
| 52 | + }, |
| 53 | + { |
| 54 | + find: /^@objectstack\/service-automation$/, |
| 55 | + replacement: path.resolve(__dirname, '../../services/service-automation/src/index.ts'), |
| 56 | + }, |
| 57 | + ], |
| 58 | + }, |
| 59 | +}); |
0 commit comments