@starci/jest-preset 2.2.1 → 2.2.3

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.2.2 - 2026-10-01
4
+
5
+ - Changed: the coverage reporters are `text-summary`, `text` and `lcov`. The unit run writes `coverage/lcov.info`, which Sonar (`sonar.javascript.lcov.reportPaths`) and Codecov import with the scope `hfs sync` renders from `COVERAGE_SOURCES` (services only). Coverage is still collected from `src/**/*.service.ts` only, with the per-file threshold of 100. Contract change `sonar-services-coverage`.
6
+
3
7
  ## 2.2.1 - 2026-10-01
4
8
 
5
9
  - Changed: declares its test toolchain as devDependencies and @jest/globals as an optional peer, with a lockfile (lane PKGT clean proof); no preset change. The published package.json differs from 2.2.0, so the version moves.
package/README.md CHANGED
@@ -32,10 +32,12 @@ module.exports = require("@starci/jest-preset").starciJestConfig()
32
32
  real source. The unit project overlays `isolatedModules: false` and `importHelpers: true` on the repository tsconfig (ts-jest merges an
33
33
  inline `tsconfig` object over the `tsconfig.json` it finds): with `isolatedModules` on, TypeScript emits an unreachable
34
34
  `typeof Dep !== "undefined" ? Dep : Object` guard per class-typed constructor parameter, and inlined decorator helpers carry branches
35
- of their own, so 100 would be unreachable. The repository lists `tslib` in its devDependencies (`UNIT_COMPILER_OPTIONS`). Reporters are `text-summary` and
36
- `text`; there is no `lcov`.
37
- - **Sonar does not read coverage.** `sonarCoverageExclusions()` and the lcov report are removed. `sonarExclusions()` still renders
38
- `sonar.exclusions` (`**/*.spec.ts,**/*.e2e-spec.ts,**/dist/**,**/coverage/**`); the quality gate fails on imported issues only.
35
+ of their own, so 100 would be unreachable. The repository lists `tslib` in its devDependencies (`UNIT_COMPILER_OPTIONS`). Reporters are `text-summary`,
36
+ `text` and `lcov`: the run writes `coverage/lcov.info` under the repository (be/) root.
37
+ - **Sonar and Codecov import that lcov, scoped to the services.** `hfs sync` renders `sonar.coverage.exclusions` (the complement of the services: SonarQube has no coverage inclusions) and the `codecov.yml`
38
+ status paths from `COVERAGE_SOURCES` on the be side (`be/src/**/*.service.ts`), so jest, Sonar and Codecov measure the same files;
39
+ the Sonar gate holds coverage at 100 overall, on new code and per file. `sonarExclusions()` still renders `sonar.exclusions`
40
+ (`**/*.spec.ts,**/*.e2e-spec.ts,**/dist/**,**/coverage/**`). There is no coverage exclusion list.
39
41
 
40
42
  ## The unit standard in one page
41
43
 
package/index.cjs CHANGED
@@ -13,7 +13,8 @@ const { fakeIds, FakeIds } = require("./ids.cjs")
13
13
  * Coverage is measured on services only: the one place business logic lives (owner-locked unit standard). Handlers,
14
14
  * resolvers, controllers and consumers are thin, and helpers called by a service are covered through the service's own
15
15
  * spec, so every `*.service.ts` under `src` is the whole denominator and every file in it must reach 100 on every metric.
16
- * Sonar does not read coverage at all (the gate fails on imported issues only), so there is no second list to keep in step.
16
+ * The unit run also writes `coverage/lcov.info`: Sonar imports it (`sonar.javascript.lcov.reportPaths`) with the same scope
17
+ * (`sonar.coverage.exclusions` holds every other file, rendered by hfs sync) and its quality gate holds coverage at 100 on those files.
17
18
  */
18
19
  const COVERAGE_SOURCES = ["src/**/*.service.ts"]
19
20
  const COVERAGE_EXCLUDES = ["src/tests/**", "**/dist/**", "**/coverage/**"]
@@ -87,7 +88,7 @@ const underTests = (folder) => String.raw`[\\/]src[\\/]tests[\\/]` + folder + St
87
88
  * run their spec files one at a time, each in a worker process of its own (`world-runner.cjs`; every file shares the
88
89
  * run's data, so the runner never runs two at once); the unit project alone has a `setupFilesAfterEnv` (the Outcome matchers).
89
90
  * Coverage is collected from every `*.service.ts` only, with a per-file threshold of 100 on lines, branches, functions and
90
- * statements: the `test` script runs the unit project with `--coverage` and fails below it. It uses v8: istanbul instruments the helpers TypeScript emits (`__decorate`, `__param`, `__awaiter`, interop wrappers)
91
+ * 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)
91
92
  * as thousands of branches no spec can cover, while v8 measures the real source.
92
93
  */
93
94
  /** The runner of the integration, e2e and contract projects: one fresh worker process per spec file. */
@@ -125,7 +126,8 @@ function starciJestConfig() {
125
126
  // A glob key is applied to every matching file on its own: each service file must reach 100, not the average.
126
127
  coverageThreshold: { "./src/**/*.service.ts": { ...COVERAGE_THRESHOLD } },
127
128
  coverageDirectory: "coverage",
128
- coverageReporters: ["text-summary", "text"],
129
+ // lcov is what Sonar imports (coverage/lcov.info); text-summary and text are what the developer reads.
130
+ coverageReporters: ["text-summary", "text", "lcov"],
129
131
  projects: [
130
132
  {
131
133
  ...shared,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/jest-preset",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
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(), recordingOutbox(), FakeClock, fakeIds(), builder() and the Outcome matchers toBeRefused/toSucceedWith.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -51,7 +51,7 @@
51
51
  "files": [
52
52
  "*.cjs",
53
53
  "*.d.ts",
54
- "!*.test.*",
54
+ "!*.spec.*",
55
55
  "README.md",
56
56
  "CHANGELOG.md"
57
57
  ],
@@ -66,7 +66,7 @@
66
66
  "@jest/globals": ">=29"
67
67
  },
68
68
  "scripts": {
69
- "test": "node --test \"*.test.mjs\""
69
+ "test": "node --test \"*.spec.mjs\""
70
70
  },
71
71
  "peerDependenciesMeta": {
72
72
  "typeorm": {