In my nx monorepo, I have two apps (client, server) and 5 libraries (client-core, platform-core, etc). To include the libraries in the Angular client application, I set the paths in the tsconfig.json file.
"paths": {
"@myorg/platform-core": [
"../../libs/platform-core/src/index.ts"
],
"@myorg/client-core": [
"../../libs/client-core/src/index.ts"
],
},
Everything works smoothly, as the IDE can resolve the libraries and I can run the application using ng serve. However, when I try to test the angular application with npx nx test client, it fails to locate 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 attempted adding the same paths to tsconfig.spec.json (even though it should not be necessary since it extends 'tsconfig.json'), but that did not solve the issue.
What steps should I take to access these libraries from my spec files?