You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I am currently building an environment for AWS together with the SST framework.
I made a Lambda with an express server behind it and this is currently what I am trying to setup jest for.
This is my current file structure:
Root:
- packages
- core
- functions <-- location of my express server
- portal
- stacks
So inside my functions directory I have a separate package.json, tsconfig.json and jest.config.ts file.
Now my tests work but I am unable to access the core directory.
In my tsconfig I have the following path configured:
Which does work for paths like: @packages/core/controllers, but not when a subpath is added as it is unable to resolve it and gives the following error:
Configuration error:
Could not locate module @packages/core/src/utils/database mapped as:
D:\test\aws\myProject\packages\core\src\$1.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/@packages\/core\/(.*)/": "D:\test\aws\myProject\packages\core\src\$1"
},
"resolver": undefined
}
The only way I could get it to work was if I changed my import, from using "/" to using "\" as then it was able to resolve it without an issue. Probably because its trying to resolve the path like this:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
So I am currently building an environment for AWS together with the SST framework.
I made a Lambda with an express server behind it and this is currently what I am trying to setup jest for.
This is my current file structure:
So inside my functions directory I have a separate package.json, tsconfig.json and jest.config.ts file.
Now my tests work but I am unable to access the core directory.
In my tsconfig I have the following path configured:
I tried to add this inside my jest config like this:
Which does work for paths like:
@packages/core/controllers
, but not when a subpath is added as it is unable to resolve it and gives the following error:The only way I could get it to work was if I changed my import, from using "/" to using "\" as then it was able to resolve it without an issue. Probably because its trying to resolve the path like this:
Which obviously doesn't work.
So now my question is am I doing something wrong here do I need to change my configuration or do I just update my imports to use "\" instead?
FYI, I am using the following dependencies:
Hope someone can clear this out for me!
Thanks in advance!
Kind regards,
Billy
Beta Was this translation helpful? Give feedback.
All reactions