Compare commits

...

2 Commits

Author SHA1 Message Date
Julien Gautier cd1d482aa8 fix(portal-shell): make 'nx test' run once by default, add watch configuration
The Angular 21 unit-test builder (@angular/build:unit-test) defaults
to watch mode. Without an explicit option, 'pnpm nx test portal-shell'
hangs on 'Waiting for task' indefinitely - unsuitable for CI and
surprising for ad-hoc invocations.

Pin watch=false as the default in the target options. Add a 'watch'
configuration so developers who want continuous test running can opt
in with 'pnpm nx test portal-shell --configuration=watch'. portal-bff
uses Jest which defaults to no-watch and needs no change.
2026-04-30 16:44:33 +02:00
Julien Gautier 0774014599 fix(portal-bff): use bracket notation for process.env access
The strict-TS option noPropertyAccessFromIndexSignature: true (set in
tsconfig.base.json per ADR-0004) forbids dot-notation access on index
signatures. process.env is typed as { [key: string]: string | undefined }
so process.env.PORT must be written process.env['PORT']. The Nx
generator wrote the dot form by default; fix to comply with the
project's strict-TS bar.

Touched: portal-bff main.ts and the three portal-bff-e2e support files
(global-setup, global-teardown, test-setup).
2026-04-30 16:34:17 +02:00
5 changed files with 14 additions and 7 deletions
@@ -7,8 +7,8 @@ module.exports = async function () {
// Start services that that the app needs to run (e.g. database, docker-compose, etc.). // Start services that that the app needs to run (e.g. database, docker-compose, etc.).
console.log('\nSetting up...\n'); console.log('\nSetting up...\n');
const host = process.env.HOST ?? 'localhost'; const host = process.env['HOST'] ?? 'localhost';
const port = process.env.PORT ? Number(process.env.PORT) : 3000; const port = process.env['PORT'] ? Number(process.env['PORT']) : 3000;
await waitForPortOpen(port, { host }); await waitForPortOpen(port, { host });
// Hint: Use `globalThis` to pass variables to global teardown. // Hint: Use `globalThis` to pass variables to global teardown.
@@ -4,7 +4,7 @@ import { killPort } from '@nx/node/utils';
module.exports = async function () { module.exports = async function () {
// Put clean up logic here (e.g. stopping services, docker-compose, etc.). // Put clean up logic here (e.g. stopping services, docker-compose, etc.).
// Hint: `globalThis` is shared between setup and teardown. // Hint: `globalThis` is shared between setup and teardown.
const port = process.env.PORT ? Number(process.env.PORT) : 3000; const port = process.env['PORT'] ? Number(process.env['PORT']) : 3000;
await killPort(port); await killPort(port);
console.log(globalThis.__TEARDOWN_MESSAGE__); console.log(globalThis.__TEARDOWN_MESSAGE__);
}; };
@@ -3,7 +3,7 @@ import axios from 'axios';
module.exports = async function () { module.exports = async function () {
// Configure axios for tests to use. // Configure axios for tests to use.
const host = process.env.HOST ?? 'localhost'; const host = process.env['HOST'] ?? 'localhost';
const port = process.env.PORT ?? '3000'; const port = process.env['PORT'] ?? '3000';
axios.defaults.baseURL = `http://${host}:${port}`; axios.defaults.baseURL = `http://${host}:${port}`;
}; };
+1 -1
View File
@@ -18,7 +18,7 @@ async function bootstrap() {
const globalPrefix = 'api'; const globalPrefix = 'api';
app.setGlobalPrefix(globalPrefix); app.setGlobalPrefix(globalPrefix);
const port = process.env.PORT || 3000; const port = process.env['PORT'] || 3000;
await app.listen(port); await app.listen(port);
Logger.log(`Application is running on: http://localhost:${port}/${globalPrefix}`); Logger.log(`Application is running on: http://localhost:${port}/${globalPrefix}`);
} }
+8 -1
View File
@@ -64,7 +64,14 @@
}, },
"test": { "test": {
"executor": "@angular/build:unit-test", "executor": "@angular/build:unit-test",
"options": {} "options": {
"watch": false
},
"configurations": {
"watch": {
"watch": true
}
}
}, },
"serve-static": { "serve-static": {
"continuous": true, "continuous": true,