@starci/jest-preset 2.2.7 → 2.3.0
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.
- package/CHANGELOG.md +5 -0
- package/index.cjs +30 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.3.0 - 2026-10-16
|
|
4
|
+
|
|
5
|
+
- Added: a declared lite app (the edition of the `hfs.json` above its `be/`) runs its existing integration and contract specs without a test world: those projects exist only when their spec files do, and neither the world runner nor the world global setup and teardown is attached to a lite run.
|
|
6
|
+
- Changed: a full app without a test world keeps only the unit project (an unfinished full scaffold), as before; the cited ruling is now ruling:R212/case-1 amended by ruling:R212/case-4.
|
|
7
|
+
|
|
3
8
|
## 2.2.7 - 2026-10-13
|
|
4
9
|
|
|
5
10
|
- 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).
|
package/index.cjs
CHANGED
|
@@ -60,7 +60,7 @@ function transform(tsconfig) {
|
|
|
60
60
|
* The runtime dependencies of a back end that ship ECMAScript modules only: jest's CommonJS runtime cannot load them, so their
|
|
61
61
|
* files are compiled to CommonJS like the repository's own (ts-jest with `allowJs`) instead of being skipped as node_modules.
|
|
62
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 (
|
|
63
|
+
* run (ruling:R212/case-1, amended by ruling:R212/case-4), so a spec that imports its guard must load it.
|
|
64
64
|
*/
|
|
65
65
|
const ESM_ONLY_DEPENDENCIES = Object.freeze(["jose"])
|
|
66
66
|
const ESM_DEPENDENCY_TRANSFORM = String.raw`^.+[\\/]node_modules[\\/](?:${ESM_ONLY_DEPENDENCIES.join("|")})[\\/].+\.js$`
|
|
@@ -114,7 +114,7 @@ const underTests = (folder) => String.raw`[\\/]src[\\/]tests[\\/]` + folder + St
|
|
|
114
114
|
* test tree compiles against `src/tests/tsconfig.json`, the nearest config of every file under `src/tests/`. The
|
|
115
115
|
* integration, e2e and contract projects share the world's `global-setup.ts`/`global-teardown.ts` (`src/tests/world/`) and
|
|
116
116
|
* run their spec files up to `min(--maxWorkers, slots)` at once, each in a worker process of its own bound to one data slot
|
|
117
|
-
* of the test world (`world-runner.cjs`; a slot's data is reset when a file boots, so no two files ever share a slot)
|
|
117
|
+
* of the test world (`world-runner.cjs`; a slot's data is reset when a file boots, so no two files ever share a slot). A declared lite app instead runs its existing integration and contract specs without a world, on jest's stock runner. The unit project alone has a `setupFilesAfterEnv` (the Outcome matchers).
|
|
118
118
|
* Coverage is collected from the logic roles of the measured roots only (`coverage` option), with a per-file threshold of 100 on lines, branches, functions and
|
|
119
119
|
* statements: the `test` script runs the unit project with `--coverage`, fails below it and writes `coverage/lcov.info` for Sonar. It uses v8: istanbul instruments the helpers TypeScript emits (`__decorate`, `__param`, `__awaiter`, interop wrappers)
|
|
120
120
|
* as thousands of branches no spec can cover, while v8 measures the real source.
|
|
@@ -127,6 +127,16 @@ function hasTestWorld(root) {
|
|
|
127
127
|
return require("node:fs").existsSync(require("node:path").join(root, "src", "tests", "world", "global-setup.ts"))
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
/** The managed config runs in `be/`, one level below the app's edition declaration. */
|
|
131
|
+
function isLiteApp(root) {
|
|
132
|
+
try {
|
|
133
|
+
const file = require("node:path").join(root, "..", "hfs.json")
|
|
134
|
+
return JSON.parse(require("node:fs").readFileSync(file, "utf8")).edition === "lite"
|
|
135
|
+
} catch {
|
|
136
|
+
return false
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
130
140
|
/** Every alternative a `{a,b}` pattern spells, braces expanded left to right. */
|
|
131
141
|
function braceVariants(value) {
|
|
132
142
|
const match = /{([^{}]+)}/.exec(value)
|
|
@@ -189,6 +199,8 @@ function coverageOf(options) {
|
|
|
189
199
|
|
|
190
200
|
function starciJestConfig(options) {
|
|
191
201
|
const coverage = coverageOf(options)
|
|
202
|
+
const root = process.cwd()
|
|
203
|
+
const world = hasTestWorld(root)
|
|
192
204
|
const shared = {
|
|
193
205
|
preset: "ts-jest",
|
|
194
206
|
testEnvironment: "node",
|
|
@@ -201,15 +213,22 @@ function starciJestConfig(options) {
|
|
|
201
213
|
...shared,
|
|
202
214
|
transform: transform("src/tests/tsconfig.json"),
|
|
203
215
|
displayName,
|
|
204
|
-
// Every spec file in a process of its own (never in band): nothing one file or the globalSetup put on a process global
|
|
205
|
-
// (a framework registry such as @nestjs/graphql's type metadata) reaches another file. See world-runner.cjs.
|
|
206
|
-
runner: WORLD_RUNNER,
|
|
207
216
|
// 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
217
|
testMatch: [`**/src/tests/${displayName}/**/*.${suffix}.ts`],
|
|
209
|
-
//
|
|
210
|
-
|
|
211
|
-
|
|
218
|
+
// Full's world gives every spec file its own process and data slot; lite needs neither its runner nor its hooks.
|
|
219
|
+
...(world ? {
|
|
220
|
+
runner: WORLD_RUNNER,
|
|
221
|
+
globalSetup: "<rootDir>/src/tests/world/global-setup.ts",
|
|
222
|
+
globalTeardown: "<rootDir>/src/tests/world/global-teardown.ts",
|
|
223
|
+
} : {}),
|
|
212
224
|
})
|
|
225
|
+
const testProjects = world ? [suite("integration", "integration-spec"), suite("e2e", "e2e-spec"), suite("contract", "contract-spec")] : []
|
|
226
|
+
if (!world && isLiteApp(root)) {
|
|
227
|
+
for (const name of ["integration", "contract"]) {
|
|
228
|
+
const suffix = `${name}-spec`
|
|
229
|
+
if (hasCoverageSubjects(root, `src/tests/${name}/**/*.${suffix}.ts`)) testProjects.push(suite(name, suffix))
|
|
230
|
+
}
|
|
231
|
+
}
|
|
213
232
|
return {
|
|
214
233
|
testTimeout: 120_000,
|
|
215
234
|
coverageProvider: "v8",
|
|
@@ -230,10 +249,9 @@ function starciJestConfig(options) {
|
|
|
230
249
|
testMatch: ["**/*.spec.ts"],
|
|
231
250
|
testPathIgnorePatterns: ["/node_modules/", ...TEST_KIND_FOLDERS.map(underTests)],
|
|
232
251
|
},
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
...(hasTestWorld(process.cwd()) ? [suite("integration", "integration-spec"), suite("e2e", "e2e-spec"), suite("contract", "contract-spec")] : []),
|
|
252
|
+
// Jest validates every project's world hooks even under --selectProjects unit. An unfinished full scaffold
|
|
253
|
+
// keeps only unit; a lite app's present integration/contract lanes need no test world.
|
|
254
|
+
...testProjects,
|
|
237
255
|
],
|
|
238
256
|
}
|
|
239
257
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starci/jest-preset",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
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,
|