The Wayback Machine - https://web.archive.org/web/20201212162942/https://github.com/vuejs/vue-test-utils/issues/1722
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

Cannot find module 'vue' from 'vue-test-utils.js' #1722

Open
ikhidebright opened this issue Oct 21, 2020 · 1 comment
Open

Cannot find module 'vue' from 'vue-test-utils.js' #1722

ikhidebright opened this issue Oct 21, 2020 · 1 comment

Comments

@ikhidebright
Copy link

@ikhidebright ikhidebright commented Oct 21, 2020

Subject of the issue

Error: Cannot find module 'vue' from 'vue-test-utils.js'

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17)
      at Object.<anonymous> (node_modules/@vue/test-utils/dist/vue-test-utils.js:5:11)

Im trying to run jest test but it fails every time

.babelrc file

{
  "presets": [
    ["@babel/preset-env", {
      "modules": false,
      "targets": {
        "node": "10",
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
      }
    }],
    "jest"
  ],
  "plugins": ["@babel/plugin-transform-runtime"],
  "env": {
    "test": {
      "presets": ["@babel/preset-env"]
    }
  }
}

jest.config.js file

module.exports = {
  preset: '@vue/cli-plugin-unit-jest',
  "moduleFileExtensions": [
      "js",
      "json",
      // tell Jest to handle `*.vue` files
      "vue"
    ],
  "transform": {
      // process `*.vue` files with `vue-jest`
      ".*\\.(vue)$": "vue-jest",
      ".*\\.(js)$": "babel-jest"
  },
  "collectCoverage": true,
  "collectCoverageFrom": ["**/*.{js,vue}", "!**/node_modules/**"],
  "transformIgnorePatterns": ["<rootDir>/node_modules/"],
  'verbose': true,
}

versions

"vue": "^2.5.16",
"@vue/cli-plugin-unit-jest": "^4.5.8",
"@vue/test-utils": "^1.1.0",
"@babel/core": "^7.12.3",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@vue/babel-preset-app": "^4.5.8",

Expected behaviour

should run $ jest

Actual behaviour

It breaks and cannot find vue module in vue-test-utils

@lmiller1990
Copy link
Member

@lmiller1990 lmiller1990 commented Oct 28, 2020

This sounds like a config issue. Did you make this project with the Vue CLI?

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.