@abgov/nx-adsp 13.10.0 → 13.11.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/nx-adsp",
3
- "version": "13.10.0",
3
+ "version": "13.11.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "src/index.js",
6
6
  "description": "Government of Alberta - Nx plugin for ADSP apps.",
@@ -11,6 +11,10 @@ const keycloak_admin_1 = require("../../utils/keycloak-admin");
11
11
  const plugin_version_1 = require("../../utils/plugin-version");
12
12
  const quality_1 = require("../../utils/quality");
13
13
  const init_1 = require("../init/init");
14
+ // Must match environment.ts.__tmpl__'s own `PORT: num({ default: ... })` —
15
+ // there's no --port option to source this from yet, so it's a second literal
16
+ // kept in sync by convention rather than a single shared value.
17
+ const DEFAULT_PORT = 3333;
14
18
  function normalizeOptions(host, options) {
15
19
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
20
  var _a;
@@ -39,7 +43,16 @@ function default_1(host, options) {
39
43
  throw new Error("The 'express-service' generator requires the '@nx/express' plugin. Install it and re-run:\n npm i -D @nx/express");
40
44
  });
41
45
  const normalizedOptions = yield normalizeOptions(host, options);
42
- yield initExpress(host, Object.assign(Object.assign({}, options), { skipFormat: true, skipPackageJson: false, linter: eslint_1.Linter.EsLint, unitTestRunner: 'jest', js: false, directory: normalizedOptions.projectRoot }));
46
+ // @nx/express's own Schema type doesn't declare e2eTestRunner, even though
47
+ // its implementation forwards it straight through to @nx/node's own
48
+ // applicationGenerator (which does). Assigning to an inferred-type const
49
+ // first, rather than passing the object literal directly, sidesteps
50
+ // TypeScript's excess-property check on a type that's simply incomplete.
51
+ const initExpressOptions = Object.assign(Object.assign({}, options), { skipFormat: true, skipPackageJson: false, linter: eslint_1.Linter.EsLint, unitTestRunner: 'jest', e2eTestRunner: 'jest', js: false, directory: normalizedOptions.projectRoot });
52
+ yield initExpress(host, initExpressOptions);
53
+ // @nx/node:e2e-project's own generated output has two bugs of its own —
54
+ // see fixExpressServiceE2eProject's doc comment for how each was confirmed.
55
+ (0, quality_1.fixExpressServiceE2eProject)(host, `${normalizedOptions.projectRoot}-e2e`, DEFAULT_PORT);
43
56
  (0, devkit_1.addDependenciesToPackageJson)(host, Object.assign(Object.assign({ '@abgov/adsp-service-sdk': '^2.23.0', '@asteasolutions/zod-to-openapi': '^7.3.4', compression: '^1.8.1', cors: '^2.8.5', dotenv: '^16.4.7', envalid: '^8.0.0', helmet: '^8.0.0', passport: '^0.7.0', 'passport-anonymous': '^1.0.1', zod: '^3.0.0' }, (normalizedOptions.database === 'postgres'
44
57
  ? { 'drizzle-orm': '^0.44.0', pg: '^8.11.0' }
45
58
  : {})), (normalizedOptions.database === 'mongo' ? { mongoose: '^8.0.0' } : {})), Object.assign(Object.assign({ '@types/compression': '^1.7.5', '@types/cors': '^2.8.17', '@types/passport': '^1.0.16', '@types/passport-anonymous': '^1.0.3', supertest: '^7.0.0', '@types/supertest': '^6.0.0' }, (normalizedOptions.database === 'postgres'
@@ -1 +1 @@
1
- {"version":3,"file":"express-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/express-service/express-service.ts"],"names":[],"mappings":";;AAsEA,4BA8PC;;AApUD,wCAIsB;AACtB,uCAUoB;AACpB,uCAAoC;AACpC,6BAA6B;AAC7B,6CAAiD;AACjD,+DAAiE;AACjE,+DAA4D;AAC5D,iDAI6B;AAC7B,uCAAyC;AAGzC,SAAe,gBAAgB,CAC7B,IAAU,EACV,OAAe;;;QAEf,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;QACjD,MAAM,WAAW,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,IAAI,WAAW,EAAE,CAAC;QAEzE,MAAM,IAAI,GAAG,MAAM,IAAA,4BAAoB,EAAC,IAAI,EAAE,OAA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BAC9B,MAAM,EAAE,iBAAiB,CAAC,IAAI,CAAC,MAAM;gBACrC,aAAa,EAAE,+BAAc;gBAC7B,aAAa,kBACX,aAAa,EAAE,MAAM,EACrB,oBAAoB,EAAE,aAAa,EACnC,eAAe,EAAE,QAAQ,IACtB,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACzD;aACF,EACD,IAAI,EACJ,iBAAiB,CAAC,WAAW,CAC9B,CAAC;YAEF,0EAA0E;YAC1E,sEAAsE;YACtE,qEAAqE;YACrE,IAAI,WAAW,IAAI,WAAW,CAAC,YAAY,KAAK,CAAC,EAAE,CAAC;gBAClD,MAAM,EAAE,MAAM,EAAE,GAAG,2CAAa,UAAU,EAAC,CAAC;gBAC5C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAuB;oBACrD,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,SAAS;oBACf,OAAO,EACL,mFAAmF;oBACrF,OAAO,EAAE,CAAC,WAAW,CAAC,WAAW;iBAClC,CAAC,CAAC;gBACH,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;gBACzC,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,IAAA,2BAAmB,EAAC,IAAI,kCACzB,iBAAiB,KACpB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,iBAAiB,CAAC,WAAW,EACtC,QAAQ,EAAE,iBAAiB,CAAC,QAAQ,IACpC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA"}
1
+ {"version":3,"file":"express-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/express-service/express-service.ts"],"names":[],"mappings":";;AA4EA,4BA6QC;;AAzVD,wCAIsB;AACtB,uCAUoB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,2CAAa,UAAU,EAAC,CAAC;gBAC5C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAuB;oBACrD,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,SAAS;oBACf,OAAO,EACL,mFAAmF;oBACrF,OAAO,EAAE,CAAC,WAAW,CAAC,WAAW;iBAClC,CAAC,CAAC;gBACH,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;gBACzC,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,IAAA,2BAAmB,EAAC,IAAI,kCACzB,iBAAiB,KACpB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,iBAAiB,CAAC,WAAW,EACtC,QAAQ,EAAE,iBAAiB,CAAC,QAAQ,IACpC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA"}
@@ -99,6 +99,31 @@ describe('Express Service Generator', () => {
99
99
  expect(agents).toContain('search_sdk_reference');
100
100
  }, 60000);
101
101
 
102
+ it('scaffolds a Jest e2e project with the port default fixed to match environment.ts', async () => {
103
+ const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
104
+ await generator(host, options);
105
+
106
+ const e2eRoot = 'apps/test-e2e';
107
+ expect(host.exists(`${e2eRoot}/jest.config.cts`)).toBeTruthy();
108
+
109
+ // @nx/node:e2e-project's own template hardcodes a fallback port of 3000;
110
+ // nx-adsp's own environment.ts.__tmpl__ defaults PORT to 3333. Which of
111
+ // @nx/node's two jest.config.cts shapes (ts-jest vs. @swc/jest — see
112
+ // fixExpressServiceE2eProject's own tests for that variance) this
113
+ // workspace produces isn't deterministic here, but the port fix applies
114
+ // to both identically.
115
+ for (const file of ['global-setup.ts', 'global-teardown.ts']) {
116
+ const content = host.read(`${e2eRoot}/src/support/${file}`).toString();
117
+ expect(content).not.toContain(': 3000');
118
+ expect(content).toContain(': 3333');
119
+ }
120
+ const testSetup = host
121
+ .read(`${e2eRoot}/src/support/test-setup.ts`)
122
+ .toString();
123
+ expect(testSetup).not.toContain("?? '3000'");
124
+ expect(testSetup).toContain("?? '3333'");
125
+ }, 60000);
126
+
102
127
  it('merges .mcp.json without clobbering other servers or a customized entry', async () => {
103
128
  const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
104
129
  writeJson(host, '.mcp.json', {
@@ -9,9 +9,19 @@ import { Tree } from '@nx/devkit';
9
9
  */
10
10
  export declare function addEslintQualityRules(host: Tree, projectRoot: string, testFileGlobs: string[]): void;
11
11
  /**
12
- * Adds collectCoverage and a 60% line coverage threshold to the project's
13
- * jest.config.cts. The threshold is inactive until the first test file is
14
- * added (passWithNoTests exits before coverage is checked).
12
+ * Adds collectCoverage, a 60% line coverage threshold, and terminal-visible
13
+ * coverage reporters to the project's jest.config.cts. The threshold is
14
+ * inactive until the first test file is added (passWithNoTests exits before
15
+ * coverage is checked).
16
+ *
17
+ * @nx/jest's shared preset sets `coverageReporters: ['html']` — a report
18
+ * written to disk, with nothing printed to the terminal even when coverage
19
+ * runs. That's a real gap for a coding agent, whose main feedback loop *is*
20
+ * the terminal: a threshold failure alone only says the aggregate number
21
+ * dropped, not which files or lines are under it. `text` is set directly in
22
+ * this project's own jest.config.cts (overriding the preset's list for this
23
+ * project only, without touching the shared preset every other project
24
+ * inherits) so every `nx test` run prints the full per-file breakdown.
15
25
  */
16
26
  export declare function addJestCoverageConfig(host: Tree, projectRoot: string): void;
17
27
  /**
@@ -39,6 +49,60 @@ export declare function addSemgrepTarget(host: Tree, projectName: string): void;
39
49
  * Idempotent and a no-op if the config lacks a webServer or is already guarded.
40
50
  */
41
51
  export declare function guardPlaywrightWebServer(host: Tree, e2eProjectRoot: string): void;
52
+ /**
53
+ * Fixes two bugs that surface when e2e testing is added to express-service,
54
+ * confirmed by actually running the generated `e2e` target rather than just
55
+ * inspecting the templates. The two have different owners — kept together
56
+ * here only because both need fixing at the same call site, not because
57
+ * they share a cause:
58
+ *
59
+ * 1. UPSTREAM BUG, not nx-adsp's — lives entirely inside `@nx/node`'s own
60
+ * `e2e-project` generator (triggered here via `e2eTestRunner: 'jest'` on
61
+ * the express application generator). Nothing about nx-adsp's own code
62
+ * causes it, and it would reproduce in a plain `@nx/node`/`@nx/express`
63
+ * workspace with no nx-adsp involved at all. Kept as a local workaround
64
+ * anyway since nx-adsp doesn't control Nx's release cadence and a safe
65
+ * no-op against already-correct output (see below) costs nothing if
66
+ * upstream fixes it later — worth reporting to `nrwl/nx` regardless.
67
+ *
68
+ * `@nx/node:e2e-project` writes one of two shapes for `jest.config.cts`
69
+ * depending on whether `@swc/jest` is present in the workspace — not
70
+ * necessarily for this project itself; a Vue/React app elsewhere in a
71
+ * multi-app workspace pulling in `@swc/core` for its own build is enough
72
+ * to flip it. The `@swc/jest` shape is `export default {...}` with a
73
+ * top-level `import` — ESM syntax in a `.cts` file, which Node/ts-jest/SWC
74
+ * always treat as CommonJS regardless of the workspace's own
75
+ * `package.json` "type". Jest's own config loader (unlike its `transform`
76
+ * pipeline, which only applies to *test* files) can't reconcile the two,
77
+ * so the config fails to parse before a single test runs — every target
78
+ * that reads it breaks outright with `SyntaxError: Cannot use import
79
+ * statement outside a module`. Rewritten to `const {...} = require(...)`
80
+ * / `module.exports = {...}`, matching both the pattern the service's own
81
+ * `jest.config.cts` already uses correctly and the ts-jest shape
82
+ * `@nx/node` writes when `@swc/jest` isn't present — which needs no fix,
83
+ * so the two replaces below are safe no-ops against it.
84
+ *
85
+ * (`src/support/*.ts` also import at the top level, but — verified by
86
+ * running the target — those are plain `.ts` files that DO go through
87
+ * the config's `transform` pipeline, so they don't need this fix; only
88
+ * the config file itself, read before that pipeline exists, does.)
89
+ *
90
+ * 2. OUR OWN BUG, not Nx's — a convention mismatch entirely on nx-adsp's
91
+ * side, not a defect in the upstream generator. `@nx/node:e2e-project`'s
92
+ * fallback port of `3000` is a reasonable generic default with no
93
+ * knowledge of any particular caller; it's only wrong here because
94
+ * nx-adsp's own `environment.ts.__tmpl__` defaults `PORT` to `3333`
95
+ * instead (matching `@nx/express`'s own scaffolded `main.ts` before
96
+ * nx-adsp replaces it), and until this fix nothing reconciled the two.
97
+ * There's no upstream fix to wait for — reconciling nx-adsp's own port
98
+ * convention with whatever generates the e2e project is squarely
99
+ * nx-adsp's job. Confirmed via a real run:
100
+ * the express app logs `Listening at http://localhost:3333`, while
101
+ * `global-setup.ts` waits on `3000` and never sees it open — the target
102
+ * hangs, then fails with `Jest: Got error running globalSetup ...
103
+ * reason: [AggregateError]`, no port number anywhere in the message.
104
+ */
105
+ export declare function fixExpressServiceE2eProject(host: Tree, e2eProjectRoot: string, port: number): void;
42
106
  export declare function addVsCodeSettings(host: Tree): void;
43
107
  /**
44
108
  * Registers the @abgov/adsp-sdk-mcp-server MCP server in the workspace-root
@@ -4,6 +4,7 @@ exports.addEslintQualityRules = addEslintQualityRules;
4
4
  exports.addJestCoverageConfig = addJestCoverageConfig;
5
5
  exports.addSemgrepTarget = addSemgrepTarget;
6
6
  exports.guardPlaywrightWebServer = guardPlaywrightWebServer;
7
+ exports.fixExpressServiceE2eProject = fixExpressServiceE2eProject;
7
8
  exports.addVsCodeSettings = addVsCodeSettings;
8
9
  exports.addAdspMcpServer = addAdspMcpServer;
9
10
  const devkit_1 = require("@nx/devkit");
@@ -50,9 +51,19 @@ export default [
50
51
  `);
51
52
  }
52
53
  /**
53
- * Adds collectCoverage and a 60% line coverage threshold to the project's
54
- * jest.config.cts. The threshold is inactive until the first test file is
55
- * added (passWithNoTests exits before coverage is checked).
54
+ * Adds collectCoverage, a 60% line coverage threshold, and terminal-visible
55
+ * coverage reporters to the project's jest.config.cts. The threshold is
56
+ * inactive until the first test file is added (passWithNoTests exits before
57
+ * coverage is checked).
58
+ *
59
+ * @nx/jest's shared preset sets `coverageReporters: ['html']` — a report
60
+ * written to disk, with nothing printed to the terminal even when coverage
61
+ * runs. That's a real gap for a coding agent, whose main feedback loop *is*
62
+ * the terminal: a threshold failure alone only says the aggregate number
63
+ * dropped, not which files or lines are under it. `text` is set directly in
64
+ * this project's own jest.config.cts (overriding the preset's list for this
65
+ * project only, without touching the shared preset every other project
66
+ * inherits) so every `nx test` run prints the full per-file breakdown.
56
67
  */
57
68
  function addJestCoverageConfig(host, projectRoot) {
58
69
  const jestPath = `${projectRoot}/jest.config.cts`;
@@ -63,7 +74,7 @@ function addJestCoverageConfig(host, projectRoot) {
63
74
  // it with one before the inserted properties. @nx/jest may leave
64
75
  // coverageDirectory as the last property (no trailing comma), so appending
65
76
  // properties after it verbatim would produce an invalid object literal.
66
- const modified = existing.replace(/([ \t]*coverageDirectory:[^\n]*?),?\n/, `$1,\n collectCoverage: true,\n coverageThreshold: {\n global: {\n lines: 60,\n },\n },\n`);
77
+ const modified = existing.replace(/([ \t]*coverageDirectory:[^\n]*?),?\n/, `$1,\n collectCoverage: true,\n coverageReporters: ['html', 'text'],\n coverageThreshold: {\n global: {\n lines: 60,\n },\n },\n`);
67
78
  if (modified !== existing) {
68
79
  host.write(jestPath, modified);
69
80
  }
@@ -116,6 +127,86 @@ function guardPlaywrightWebServer(host, e2eProjectRoot) {
116
127
  return;
117
128
  }
118
129
  }
130
+ /**
131
+ * Fixes two bugs that surface when e2e testing is added to express-service,
132
+ * confirmed by actually running the generated `e2e` target rather than just
133
+ * inspecting the templates. The two have different owners — kept together
134
+ * here only because both need fixing at the same call site, not because
135
+ * they share a cause:
136
+ *
137
+ * 1. UPSTREAM BUG, not nx-adsp's — lives entirely inside `@nx/node`'s own
138
+ * `e2e-project` generator (triggered here via `e2eTestRunner: 'jest'` on
139
+ * the express application generator). Nothing about nx-adsp's own code
140
+ * causes it, and it would reproduce in a plain `@nx/node`/`@nx/express`
141
+ * workspace with no nx-adsp involved at all. Kept as a local workaround
142
+ * anyway since nx-adsp doesn't control Nx's release cadence and a safe
143
+ * no-op against already-correct output (see below) costs nothing if
144
+ * upstream fixes it later — worth reporting to `nrwl/nx` regardless.
145
+ *
146
+ * `@nx/node:e2e-project` writes one of two shapes for `jest.config.cts`
147
+ * depending on whether `@swc/jest` is present in the workspace — not
148
+ * necessarily for this project itself; a Vue/React app elsewhere in a
149
+ * multi-app workspace pulling in `@swc/core` for its own build is enough
150
+ * to flip it. The `@swc/jest` shape is `export default {...}` with a
151
+ * top-level `import` — ESM syntax in a `.cts` file, which Node/ts-jest/SWC
152
+ * always treat as CommonJS regardless of the workspace's own
153
+ * `package.json` "type". Jest's own config loader (unlike its `transform`
154
+ * pipeline, which only applies to *test* files) can't reconcile the two,
155
+ * so the config fails to parse before a single test runs — every target
156
+ * that reads it breaks outright with `SyntaxError: Cannot use import
157
+ * statement outside a module`. Rewritten to `const {...} = require(...)`
158
+ * / `module.exports = {...}`, matching both the pattern the service's own
159
+ * `jest.config.cts` already uses correctly and the ts-jest shape
160
+ * `@nx/node` writes when `@swc/jest` isn't present — which needs no fix,
161
+ * so the two replaces below are safe no-ops against it.
162
+ *
163
+ * (`src/support/*.ts` also import at the top level, but — verified by
164
+ * running the target — those are plain `.ts` files that DO go through
165
+ * the config's `transform` pipeline, so they don't need this fix; only
166
+ * the config file itself, read before that pipeline exists, does.)
167
+ *
168
+ * 2. OUR OWN BUG, not Nx's — a convention mismatch entirely on nx-adsp's
169
+ * side, not a defect in the upstream generator. `@nx/node:e2e-project`'s
170
+ * fallback port of `3000` is a reasonable generic default with no
171
+ * knowledge of any particular caller; it's only wrong here because
172
+ * nx-adsp's own `environment.ts.__tmpl__` defaults `PORT` to `3333`
173
+ * instead (matching `@nx/express`'s own scaffolded `main.ts` before
174
+ * nx-adsp replaces it), and until this fix nothing reconciled the two.
175
+ * There's no upstream fix to wait for — reconciling nx-adsp's own port
176
+ * convention with whatever generates the e2e project is squarely
177
+ * nx-adsp's job. Confirmed via a real run:
178
+ * the express app logs `Listening at http://localhost:3333`, while
179
+ * `global-setup.ts` waits on `3000` and never sees it open — the target
180
+ * hangs, then fails with `Jest: Got error running globalSetup ...
181
+ * reason: [AggregateError]`, no port number anywhere in the message.
182
+ */
183
+ function fixExpressServiceE2eProject(host, e2eProjectRoot, port) {
184
+ const jestConfigPath = `${e2eProjectRoot}/jest.config.cts`;
185
+ if (host.exists(jestConfigPath)) {
186
+ const cfg = host
187
+ .read(jestConfigPath)
188
+ .toString()
189
+ .replace(/^import \{([^}]+)\} from '([^']+)';$/m, "const {$1} = require('$2');")
190
+ .replace(/^export default \{/m, 'module.exports = {');
191
+ host.write(jestConfigPath, cfg);
192
+ }
193
+ for (const file of ['global-setup.ts', 'global-teardown.ts']) {
194
+ const path = `${e2eProjectRoot}/src/support/${file}`;
195
+ if (!host.exists(path))
196
+ continue;
197
+ host.write(path, host
198
+ .read(path)
199
+ .toString()
200
+ .replace(/process\.env\.PORT \? Number\(process\.env\.PORT\) : 3000/, `process.env.PORT ? Number(process.env.PORT) : ${port}`));
201
+ }
202
+ const testSetupPath = `${e2eProjectRoot}/src/support/test-setup.ts`;
203
+ if (host.exists(testSetupPath)) {
204
+ host.write(testSetupPath, host
205
+ .read(testSetupPath)
206
+ .toString()
207
+ .replace(/process\.env\.PORT \?\? '3000'/, `process.env.PORT ?? '${port}'`));
208
+ }
209
+ }
119
210
  function addVsCodeSettings(host) {
120
211
  const settingsPath = '.vscode/settings.json';
121
212
  const settings = {
@@ -1 +1 @@
1
- {"version":3,"file":"quality.js","sourceRoot":"","sources":["../../../../../packages/nx-adsp/src/utils/quality.ts"],"names":[],"mappings":";;AAgBA,sDA0CC;AAOD,sDAgBC;AAOD,4CAeC;AAoBD,4DAmBC;AAED,8CAkBC;AAiBD,4CAqBC;AAxMD,uCAMoB;AAEpB;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,IAAU,EACV,WAAmB,EACnB,aAAuB;;IAEvB,MAAM,UAAU,GAAG,GAAG,WAAW,oBAAoB,CAAC;IACtD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;QAAE,OAAO;IAErC,MAAM,QAAQ,GAAG,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C,GAAG,CACT,gEAAgE;QAC9D,iFAAiF;QACjF,+EAA+E,CAClF,CAAC;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3
- import { addJestCoverageConfig } from './quality';
3
+ import { addJestCoverageConfig, fixExpressServiceE2eProject } from './quality';
4
4
 
5
5
  function makeConfig(coverageDirectoryLine: string): string {
6
6
  return [
@@ -38,11 +38,13 @@ describe('addJestCoverageConfig', () => {
38
38
 
39
39
  expect(out).toContain("coverageDirectory: 'test-output/jest/coverage',");
40
40
  expect(out).toContain('collectCoverage: true,');
41
+ expect(out).toContain("coverageReporters: ['html', 'text'],");
41
42
  expect(out).toContain('lines: 60,');
42
43
  expect(out).not.toContain(',,');
43
44
  // The result must be a valid object literal.
44
45
  const cfg = evalConfigObject(out);
45
46
  expect(cfg.collectCoverage).toBe(true);
47
+ expect(cfg.coverageReporters).toEqual(['html', 'text']);
46
48
  expect(
47
49
  (cfg.coverageThreshold as { global: { lines: number } }).global.lines,
48
50
  ).toBe(60);
@@ -67,3 +69,153 @@ describe('addJestCoverageConfig', () => {
67
69
  expect(tree.exists('apps/none/jest.config.cts')).toBe(false);
68
70
  });
69
71
  });
72
+
73
+ describe('fixExpressServiceE2eProject', () => {
74
+ let tree: Tree;
75
+ beforeEach(() => {
76
+ tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
77
+ });
78
+
79
+ // Byte-for-byte what @nx/node:e2e-project actually writes when the
80
+ // workspace has @swc/jest available — confirmed via a real `nx e2e` run,
81
+ // which failed to parse with exactly this shape.
82
+ const SWC_JEST_CONFIG = `/* eslint-disable */
83
+ import { readFileSync } from 'fs';
84
+
85
+ // Reading the SWC compilation config for the spec files
86
+ const swcJestConfig = JSON.parse(
87
+ readFileSync(\`\${__dirname}/.spec.swcrc\`, 'utf-8'),
88
+ );
89
+
90
+ // Disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves
91
+ swcJestConfig.swcrc = false;
92
+
93
+ export default {
94
+ displayName: '@org/test-service-e2e',
95
+ preset: '../jest.preset.js',
96
+ globalSetup: '<rootDir>/src/support/global-setup.ts',
97
+ globalTeardown: '<rootDir>/src/support/global-teardown.ts',
98
+ setupFiles: ['<rootDir>/src/support/test-setup.ts'],
99
+ testEnvironment: 'node',
100
+ transform: {
101
+ '^.+\\\\.[tj]s$': ['@swc/jest', swcJestConfig],
102
+ },
103
+ moduleFileExtensions: ['ts', 'js', 'html'],
104
+ coverageDirectory: 'test-output/jest/coverage',
105
+ };
106
+ `;
107
+
108
+ // What @nx/node:e2e-project writes when the workspace uses ts-jest instead
109
+ // (this repo's own case) — already valid CommonJS, nothing to fix.
110
+ const TS_JEST_CONFIG = `module.exports = {
111
+ displayName: 'test-e2e',
112
+ preset: '../../jest.preset.js',
113
+ globalSetup: '<rootDir>/src/support/global-setup.ts',
114
+ globalTeardown: '<rootDir>/src/support/global-teardown.ts',
115
+ setupFiles: ['<rootDir>/src/support/test-setup.ts'],
116
+ testEnvironment: 'node',
117
+ transform: {
118
+ '^.+\\\\.[tj]s$': ['ts-jest', {
119
+ tsconfig: '<rootDir>/tsconfig.spec.json',
120
+ }],
121
+ },
122
+ moduleFileExtensions: ['ts', 'js', 'html'],
123
+ coverageDirectory: '../../coverage/test-e2e',
124
+ };
125
+ `;
126
+
127
+ const GLOBAL_SETUP = `import { waitForPortOpen } from '@nx/node/utils';
128
+
129
+ /* eslint-disable */
130
+ var __TEARDOWN_MESSAGE__: string;
131
+
132
+ module.exports = async function () {
133
+ console.log('\\nSetting up...\\n');
134
+
135
+ const host = process.env.HOST ?? 'localhost';
136
+ const port = process.env.PORT ? Number(process.env.PORT) : 3000;
137
+ await waitForPortOpen(port, { host });
138
+
139
+ globalThis.__TEARDOWN_MESSAGE__ = '\\nTearing down...\\n';
140
+ };
141
+ `;
142
+
143
+ const GLOBAL_TEARDOWN = `import { killPort } from '@nx/node/utils';
144
+ /* eslint-disable */
145
+
146
+ module.exports = async function () {
147
+ const port = process.env.PORT ? Number(process.env.PORT) : 3000;
148
+ await killPort(port);
149
+ console.log(globalThis.__TEARDOWN_MESSAGE__);
150
+ };
151
+ `;
152
+
153
+ const TEST_SETUP = `/* eslint-disable */
154
+ import axios from 'axios';
155
+
156
+ module.exports = async function () {
157
+ const host = process.env.HOST ?? 'localhost';
158
+ const port = process.env.PORT ?? '3000';
159
+ axios.defaults.baseURL = \`http://\${host}:\${port}\`;
160
+ };
161
+ `;
162
+
163
+ function writeE2eProject(root: string, jestConfig: string): void {
164
+ tree.write(`${root}/jest.config.cts`, jestConfig);
165
+ tree.write(`${root}/src/support/global-setup.ts`, GLOBAL_SETUP);
166
+ tree.write(`${root}/src/support/global-teardown.ts`, GLOBAL_TEARDOWN);
167
+ tree.write(`${root}/src/support/test-setup.ts`, TEST_SETUP);
168
+ }
169
+
170
+ it('rewrites the @swc/jest variant of jest.config.cts to CommonJS', () => {
171
+ writeE2eProject('apps/svc-e2e', SWC_JEST_CONFIG);
172
+
173
+ fixExpressServiceE2eProject(tree, 'apps/svc-e2e', 3333);
174
+
175
+ const out = tree.read('apps/svc-e2e/jest.config.cts').toString();
176
+ expect(out).not.toContain('export default');
177
+ expect(out).not.toMatch(/^import /m);
178
+ expect(out).toContain('module.exports = {');
179
+ expect(out).toContain("const { readFileSync } = require('fs');");
180
+ });
181
+
182
+ it('leaves the ts-jest variant of jest.config.cts untouched (already valid CommonJS)', () => {
183
+ writeE2eProject('apps/svc-e2e', TS_JEST_CONFIG);
184
+
185
+ fixExpressServiceE2eProject(tree, 'apps/svc-e2e', 3333);
186
+
187
+ expect(tree.read('apps/svc-e2e/jest.config.cts').toString()).toBe(
188
+ TS_JEST_CONFIG,
189
+ );
190
+ });
191
+
192
+ it('fixes the hardcoded port default in all three support files', () => {
193
+ writeE2eProject('apps/svc-e2e', TS_JEST_CONFIG);
194
+
195
+ fixExpressServiceE2eProject(tree, 'apps/svc-e2e', 3333);
196
+
197
+ const setup = tree
198
+ .read('apps/svc-e2e/src/support/global-setup.ts')
199
+ .toString();
200
+ expect(setup).toContain(
201
+ 'process.env.PORT ? Number(process.env.PORT) : 3333',
202
+ );
203
+ const teardown = tree
204
+ .read('apps/svc-e2e/src/support/global-teardown.ts')
205
+ .toString();
206
+ expect(teardown).toContain(
207
+ 'process.env.PORT ? Number(process.env.PORT) : 3333',
208
+ );
209
+ const testSetup = tree
210
+ .read('apps/svc-e2e/src/support/test-setup.ts')
211
+ .toString();
212
+ expect(testSetup).toContain("process.env.PORT ?? '3333'");
213
+ });
214
+
215
+ it('is a no-op when there is no e2e project at that root', () => {
216
+ expect(() =>
217
+ fixExpressServiceE2eProject(tree, 'apps/none-e2e', 3333),
218
+ ).not.toThrow();
219
+ expect(tree.exists('apps/none-e2e/jest.config.cts')).toBe(false);
220
+ });
221
+ });