"Jest Cannot Find Module '@maxgraph/core' in Angular Application Despite Correct Configuration"

Discussão em 'Angular' iniciado por Vivin Prasannaa, Abril 29, 2025.

  1. I'm working on an Angular application where I'm using the @maxgraph/core library. I've written unit tests using Jest, but I'm encountering an issue where Jest cannot find the @maxgraph/core module. The exact error message is:

    Cannot find module '@maxgraph/core' from the component


    To resolve this, I added the following moduleNameMapper configuration in my jest.config.ts:

    moduleNameMapper: {
    "^@maxgraph/core$": "<rootDir>/node_modules/@maxgraph/core"
    }


    However, after adding this configuration, I'm getting a new error:

    Configuration error:

    Could not locate module @maxgraph/core mapped as:
    \src\frontend\node_modules\@maxgraph\core.

    at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
    at Object.require (src/app/components/xxxxxx.component.ts:6:1)
    at Object.<anonymous> (src/app/components/xxxxx.component.spec.ts:13:1)


    And the node module path is \src\frontend\node_modules@maxgraph\core [​IMG]

    Continue reading...

Compartilhe esta Página