0

Receiving the following error when running Jest

 Cannot find module '@cp-module/login/loginConstant' from 'src/module/login/loginAction.js'

loginAction.js

import * as CONST from '@cp-module/login/loginConstant';

I think because jest can't read config jsconfig.json :

{
  "compilerOptions": {
    "baseUrl": ".",
    "jsx": "react",
    "paths": {
      "@cp-asset/*": ["./src/assets/*"],
      "@cp-bootstrap/*": ["./src/bootstrap/*"],
      "@cp-component": ["src/component/index"],
      "@cp-config/*": ["src/config/*"],
      "@cp-module/*": ["src/module/*"],
      "@cp-module-auth*": ["./src/module/auth/*"],
      "@cp-style/*": ["./src/style/*"],
      "@cp-util/*": ["./src/util/*"]
    },
    "allowSyntheticDefaultImports": true
  },
  "exclude": ["node_modules"]
}

I'm looking for how to configure Jest to not fail read with paths from jsconfig.json

  • does this solve your problem? https://stackoverflow.com/questions/76686305/npm-run-test-giving-error-while-import-using-paths/76686506#76686506 you will have to update the module mapper according to your tsconfig.json files path. – Nazrul Chowdhury Jul 17 '23 at 13:31

0 Answers0