I have some helper functions inside the /src/common/helper/cash.helper.ts
. When I call this function from a module, I get the following error.
Error: Cannot find module './../../../src/common/helper/cast.helper' Require stack:
However, the e2e tests are working without any problem. Here, you can see the folder structure.
When I change the import to absolute path import { toNumber } from 'src/common/helper/cast.helper'
; It's working, but the e2e tests are not working.
What's wrong here? How can I use common functions and constants across all the modules in NestJS?
I did the following to fix the issue.
{ toNumber } from 'src/common/helper/cast.helper'
;"moduleDirectories": ["<rootDir>/../", "node_modules"]
to the jest-e2e.json.