'Vue 3: Cannot resolve "@vue/vue3-jest" module. on GitHub Actions
When running my unit tests in GitHub actions after upgrading to Vue 3, I get the following error:
> vue-cli-service test:unit
● Validation Error:
An unknown error occurred in @vue/cli-plugin-unit-jest:
Cannot resolve "@vue/vue3-jest" module. Please make sure you have installed "@vue/vue3-jest" as a dev dependency.
The GitHub actions script uses npm ci as its previous step to install dependencies, and the test command vue-cli-service test:unit works locally.
My package.json has:
"devDependencies": {
"@babel/core": "^7.16.7",
"@babel/eslint-parser": "^7.16.5",
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
"@storybook/addon-a11y": "^6.4.12",
"@storybook/addon-actions": "^6.4.12",
"@storybook/addon-essentials": "^6.4.12",
"@storybook/addon-links": "^6.4.12",
"@storybook/addon-storysource": "^6.4.12",
"@storybook/vue": "^6.4.12",
"@testing-library/dom": "^7.31.2",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/user-event": "^13.2.1",
"@testing-library/vue": "^6.4.2",
"@vue/babel-preset-app": "latest",
"@vue/cli-plugin-babel": "~5.0.0-rc.2",
"@vue/cli-plugin-e2e-cypress": "~5.0.0-rc.2",
"@vue/cli-plugin-eslint": "~5.0.0-rc.2",
"@vue/cli-plugin-router": "~5.0.0-rc.2",
"@vue/cli-plugin-unit-jest": "^5.0.0-rc.1",
"@vue/cli-service": "~5.0.0-rc.2",
"@vue/cli-shared-utils": "^4.5.10",
"@vue/eslint-config-airbnb": "^6.0.0",
"@vue/preload-webpack-plugin": "^1.1.2",
"@vue/test-utils": "^2.0.0-rc.18",
"@vue/vue3-jest": "^27.0.0-alpha.4",
...
"babel-loader": "^8.2.2",
...
"jest": "^27.1.0",
"jest-extended": "^0.11.5",
"jest-junit": "^8.0.0",
...
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1",
},
and my jest.config.js matching the docs in using @vue/vue3-jest:
"transform": {
"^.+\\.vue$": "@vue/vue3-jest"
},
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
