Convert ServiceChain plugin to NestJS module#2019
Convert ServiceChain plugin to NestJS module#2019StephaneTrebel wants to merge 4 commits intomainfrom
Conversation
|
🤖 Hey ! The security scan report for the current pull request is available here. |
d1bbe44 to
23cc295
Compare
23cc295 to
3f689e8
Compare
fb683c2 to
4e7ad49
Compare
apps/server-nestjs/src/cpin-module/infrastructure/auth/admin-permission.guard.spec.ts
Fixed
Show fixed
Hide fixed
1f719cd to
8f6bfdc
Compare
|
🤖 Hey ! A preview of the application is available at : https://console-pr-2019.dso.cpin-hp.numerique-interieur.fr Please be patient, deployment may take a few minutes. |
8f6bfdc to
8d74ca8
Compare
shikanime
left a comment
There was a problem hiding this comment.
On utilise NestJS, autant reellement utiliser le framework a fond via @nestjs/testing avec un typage fort jusqu'au mocks. J'ai eux pas mal d'occasion ou les mocks n'etait plus en sync avec les implementations reel qui ont fausse les tests
|
|
||
| beforeEach(() => { | ||
| prisma = makePrisma() | ||
| service = new AuthService(prisma as any) |
There was a problem hiding this comment.
Pour les dépendances tierces, j'utilisais spécifiquement "vitest-mock-extended". Pour nos dépendances, j'utilisais principalement satisfies Partial<xxxService>; sans, les changements sur la classe principale ne seront pas détectés par TypeScript sur les mocks.
| vi.mock('../infrastructure/telemetry/telemetry.decorator', () => ({ | ||
| StartActiveSpan: () => (_target: any, _key: string, descriptor: PropertyDescriptor) => descriptor, | ||
| })) | ||
|
|
There was a problem hiding this comment.
Test.createTestingModule peut permettre de mock les modules via la DI.
| service = new ServiceChainService(config) | ||
| }) | ||
|
|
||
| function mockClient(response: any) { |
There was a problem hiding this comment.
Pas refacto-friendly, on devrait typer ca dans un service et l'injecter via la DI.
| import axios from 'axios' | ||
| import { StartActiveSpan } from '../infrastructure/telemetry/telemetry.decorator' | ||
|
|
||
| const openCdsDisabledMessage = 'OpenCDS is disabled, please set OPENCDS_URL in your relevant .env file. See .env-example' |
There was a problem hiding this comment.
On devrait utiliser https://docs.nestjs.com/fundamentals/dynamic-modules ?

Issues liées
Issues numéro: #1983