@starci/jest-preset 2.2.5 → 2.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/index.cjs +20 -2
  3. package/package.json +2 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## 2.2.7 - 2026-10-13
4
+
5
+ - Fixed: the ESM-only runtime dependency `jose` (the Supabase access-token verifier of every lite back end) is compiled to CommonJS by ts-jest instead of being skipped with node_modules, so a lite app's unit run can load its guard (owner ruling 2026-10-12: lite keeps full's unit run).
6
+
7
+ ## 2.2.6 - 2026-10-08
8
+
9
+ - Fixed: the `integration`, `e2e` and `contract` projects match `**/src/tests/<layer>/**/*.<layer>-spec.ts` instead of a pattern prefixed with the root path. On Windows a root that holds a dot-named folder (a checkout under `.claude`) turned the path separator before it into a glob escape, so the contract run found 0 spec files ("No tests found") although they exist.
10
+ - Fixed: `jest-util` is a declared devDependency of the package, which its own spec requires.
11
+
12
+ ## 2.2.5 (published before this release)
4
13
 
5
14
  - Breaking (contract change `coverage-modules-logic`): `starciJestConfig({ coverage: { roots, roles, excludes } })` takes the coverage scope the managed `be/jest.config.js` renders (`hfs sync`, from the `coverage` field of the slot manifest and `ruleParams.be.logicRoles`, through `scripts/hfs/coverage-scope.mjs`), and refuses to run without it. `COVERAGE_SOURCES` is deleted: per-file 100 now holds on every logic role (service, policy, projection, guard, mapper, client, filter, interceptor, processor, step, saga, saga-step, compensation, consumer, webhook) inside the measured roots (the logic of `be/src/modules`), never on `be/src/features` (thin by R203). New exports `rootGlob` and `StarciCoverageScope`; `collectCoverageFrom(coverage)` and `hasCoverageSubjects(root, glob)` take a scope and a glob with `**` and `{a,b}`.
6
15
  - New: `fakeInbox()` (also `@starci/jest-preset/inbox`), the twin of `recordingOutbox()` for the delivery side: `claim` answers true for the first call of a (source, eventId) pair and false afterwards, `release` gives the claim back, `seen` marks a redelivery, and `claims`, `claimed`, `released`, `failNext` and `clear` let a spec assert what a consumer or a signed webhook did. A spec no longer stubs `mock<Inbox>()` by hand.
package/index.cjs CHANGED
@@ -53,9 +53,25 @@ const TS_TRANSFORM = String.raw`^.+\.ts$`
53
53
  * does not type-check.
54
54
  */
55
55
  function transform(tsconfig) {
56
- return { [TS_TRANSFORM]: ["ts-jest", { tsconfig, diagnostics: false }] }
56
+ return { [TS_TRANSFORM]: ["ts-jest", { tsconfig, diagnostics: false }], ...esmDependencyTransform() }
57
57
  }
58
58
 
59
+ /**
60
+ * The runtime dependencies of a back end that ship ECMAScript modules only: jest's CommonJS runtime cannot load them, so their
61
+ * files are compiled to CommonJS like the repository's own (ts-jest with `allowJs`) instead of being skipped as node_modules.
62
+ * `jose` is the Supabase access-token verifier of every lite back end (be.integrations.supabase); a lite app keeps full's unit
63
+ * run (owner ruling 2026-10-12), so a spec that imports its guard must load it.
64
+ */
65
+ const ESM_ONLY_DEPENDENCIES = Object.freeze(["jose"])
66
+ const ESM_DEPENDENCY_TRANSFORM = String.raw`^.+[\\/]node_modules[\\/](?:${ESM_ONLY_DEPENDENCIES.join("|")})[\\/].+\.js$`
67
+
68
+ function esmDependencyTransform() {
69
+ return { [ESM_DEPENDENCY_TRANSFORM]: ["ts-jest", { tsconfig: { allowJs: true, module: "commonjs", target: "es2022", esModuleInterop: true }, diagnostics: false }] }
70
+ }
71
+
72
+ /** node_modules stay untransformed except the ESM-only dependencies above. */
73
+ const TRANSFORM_IGNORE_PATTERNS = Object.freeze([String.raw`[\\/]node_modules[\\/](?!(?:${ESM_ONLY_DEPENDENCIES.join("|")})[\\/])`])
74
+
59
75
  /**
60
76
  * The compiler options the UNIT project overlays on the repository tsconfig (ts-jest merges an inline `tsconfig` object over the
61
77
  * `tsconfig.json` it finds under `rootDir`). They exist so that per-file 100 coverage is reachable for a decorated service:
@@ -179,6 +195,7 @@ function starciJestConfig(options) {
179
195
  rootDir: ".",
180
196
  roots: ["<rootDir>/src", "<rootDir>/apps"],
181
197
  moduleNameMapper: { ...MODULE_NAME_MAPPER },
198
+ transformIgnorePatterns: [...TRANSFORM_IGNORE_PATTERNS],
182
199
  }
183
200
  const suite = (displayName, suffix) => ({
184
201
  ...shared,
@@ -187,7 +204,8 @@ function starciJestConfig(options) {
187
204
  // Every spec file in a process of its own (never in band): nothing one file or the globalSetup put on a process global
188
205
  // (a framework registry such as @nestjs/graphql's type metadata) reaches another file. See world-runner.cjs.
189
206
  runner: WORLD_RUNNER,
190
- testMatch: [`<rootDir>/src/tests/${displayName}/**/*.${suffix}.ts`],
207
+ // A glob without the root's absolute path: jest's roots (src, apps) already bound the search, and a root path that holds a dot-named folder (a checkout under `.claude`) turns its backslash separator into a glob escape on Windows, so a path-prefixed pattern would match no file.
208
+ testMatch: [`**/src/tests/${displayName}/**/*.${suffix}.ts`],
191
209
  // The one test world: started once per run of a project that has a test to run, torn down after it.
192
210
  globalSetup: "<rootDir>/src/tests/world/global-setup.ts",
193
211
  globalTeardown: "<rootDir>/src/tests/world/global-teardown.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/jest-preset",
3
- "version": "2.2.5",
3
+ "version": "2.2.7",
4
4
  "description": "The StarCi jest config for Nest repositories (unit, integration, e2e and contract projects, ts-jest with diagnostics off, per-file 100 coverage of *.service.ts only) and the one shared unit-test double kit: typed mock<T>(), mockEntityManager(), fakeTransaction(), fakeCache(), fakeLock(), recordingEventBus(), recordingQueueOutbox(), fakeInbox(), FakeClock, fakeIds(), builder() and the Outcome matchers toBeRefused/toSucceedWith.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -88,6 +88,7 @@
88
88
  "devDependencies": {
89
89
  "@types/jest": "29.5.14",
90
90
  "jest": "29.7.0",
91
+ "jest-util": "29.7.0",
91
92
  "ts-jest": "29.4.12",
92
93
  "typescript": "5.9.3"
93
94
  }