Attempting to convert this project over to jest using these instructions. I have everything working except for the files that use the paths
configuration:
"paths": {
"@fs/*": ["./src/*"],
"@test/*": ["./test/*"]
}
It looks as if when the tests are run the import statements do not resolve and this is logged:
Cannot find module '@fs/container/validation/ValidationContext' from 'Core.spec.ts'
1 | import { ValidationOptions } from "@fs/container/validation/ValidationOptions";
> 2 | import { ValidationContext } from "@fs/container/validation/ValidationContext";
| ^
3 | import { ValidationContainer } from "@fs/container/validation/ValidationContainer";
4 |
5 | import { Core1 } from "@test/core/Core1";
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:221:17)
at Object.<anonymous> (test/core/Core.spec.ts:2:1)
Is there a way to get jest/ts-jest include the @paths
while resolving imports?
jest can't honor tsconfig's path mapping as it's ts compiler time, so jest configuration should have corresponding modulenamemapper to resolve aliased paths.