I have an nx monorepo, which consists of two apps (client, server) and 5 libs (client-core, platform-core, etc). I pull the libraries into the Angular (client) application by setting the paths
in the tsconfig.json
.
"paths": {
"@myorg/platform-core": [
"../../libs/platform-core/src/index.ts"
],
"@myorg/client-core": [
"../../libs/client-core/src/index.ts"
],
},
This works fine, The IDE is able to resolve the libraries and I can serve the application with ng serve
. However when I attempt to test the angular application using npx nx test client
then it can't find the libraries.
FAIL apps/client/src/app/core/guards/patient.guard.spec.ts
● Test suite failed to run
apps/client/src/app/core/guards/patient.guard.spec.ts:4:36 - error TS2307: Cannot find module '@myorg/client-core' or its corresponding type declarations.
4 import { EnvironmentService } from '@myorg/client-core';
~~~~~~~~~~~~~~~~~~~
I have tried adding the same paths into tsconfig.spec.json
(which shouldn't be necessary as it "extends": "./tsconfig.json"
) and that had no impact.
What do I need to do to access these libraries from my spec files?