Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"moduleNameMapper" can't resolve alias #1128

Open
CapInSpase opened this issue Jun 20, 2022 · 1 comment
Open

"moduleNameMapper" can't resolve alias #1128

CapInSpase opened this issue Jun 20, 2022 · 1 comment

Comments

@CapInSpase
Copy link

Hi, I have aliases in my webpack.config.js

.addAliases({
        '~': path.resolve(__dirname, 'assets'),
        'images': path.resolve(__dirname, 'assets/base/images')
    })

But when I try to use module "moduleNameMapper" in package file for settings jest I have error

"jest": {
        "moduleFileExtensions": [
            "js",
            "ts",
            "json",
            "vue"
        ],
        "moduleNameMapper": {
            "^~/(.*)": "<rootDir>/assets/$1"
        },
        "transform": {
            ".*\\.(vue)$": "<rootDir>/node_modules/vue-jest",
            "^.+\\.js$": "<rootDir>/node_modules/babel-jest"
        },
        "collectCoverage": true,
        "transformIgnorePatterns": [
            "<rootDir>/node_modules/(?!variables/.*)"
        ],
        "coverageReporters": [
            "text",
            "html"
        ],
        "collectCoverageFrom": [
            "<rootDir>/assets/src/**"
        ],
        "testEnvironment": "jsdom"
    },

**Configuration error:

Could not locate module ~/components/Modal mapped as:
/Users/Cap/Desktop/project/assets.

Please check your configuration for these entries:
{
  "moduleNameMapper": {
    "/^~\/(.*)$/": "/Users/Cap/Desktop/project/assets"
  },
  "resolver": undefined
}**

Can anyone suggest what is the problem?

@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants