1

Blockquote

I am getting this error while testing apis

                                                                                                                          *> Configuration error:
> 
> Could not locate module ./src/classes/mail-service mapped as:
> C:\Users\ASUS\Documents\GitHub\NEOS FLOW\flow\@server\profile-service\src\$1.
> 
> Please check your configuration for these entries:
> >     {
> >       "moduleNameMapper": {
> >         "/src\/(.*)/": "C:\Users\ASUS\Documents\GitHub\NEOS FLOW\flow\@server\profile-service\src\$1"
> >       },
> >       "resolver": undefined
> >     }
> 
> 1 | import sgMail from "@sendgrid/mail";
> >         | ^
> *

this is my jest.configs.ts

module.exports = {
    preset: "ts-jest",
    testEnvironment: "node",
    coverageDirectory: "coverage",
    collectCoverageFrom: ["src/**/*.{js,ts}"],
    forceExit: true,
    coverageThreshold: {
        global: {
            branches: 0,
            functions: 0,
            lines: 0,
            statements: 0,
        },
    },
    moduleNameMapper: {
        "src/(.*)": "<rootDir>/src/$1",
    },
    transformIgnorePatterns: ["<rootDir>/node_modules/"],
};

As I guess this is failing because node_module is not able to find @sendgrid/mail package in it . I tried with to delete and install node_module but didn't work.

jest 29.3.1 version. Node.js v18.13.0.

Please suggest any solution. Thankyou, Have a great day.

  • Looks like could be an issue with camel case file of function names, as mentioned here https://stackoverflow.com/questions/57307668/jest-error-could-not-locate-module-mapped-as – lizziepika Feb 09 '23 at 00:34
  • @lizziepika thankyou for reply issue is resolve – Ankush Gupta Feb 15 '23 at 10:10

0 Answers0