moduleNameMapper of Jest config links to files that do not exist
See original GitHub issueWhen creating a new project with the Jest test harness (alone or with other harnesses) I run into errors when trying to run the tests.
To Reproduce Steps to reproduce the behavior:
- Create a new project:
quasar create my_project --branch next
Sass with SCSS syntax
ESLint (Prettier)
Vuex
Axios
Vue-i18n
use Yarn
cd my_project
- Install test harnesses:
quasar ext add @quasar/testing
Jest
Cypress
Quality
Security
Overwrite babel.config.js and use additional .babelrc
Extra "scripts" in your package.json
SFC webpack <test> loader
Cypress: extra "scripts" in your package.json
Lighthouse: extra "scripts" in your package.json
install the OWASP ZAP Heads Up Display
configure with Chrome
- Run
quasar test --unit jest
- See error:
FAIL test/jest/__tests__/App.spec.js
● Test suite failed to run
Configuration error:
Could not locate module vue mapped as:
vue/dist/vue.common.js.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/^vue$/": "vue/dist/vue.common.js"
},
"resolver": undefined
}
at createNoMappedModuleFoundError (node_modules/jest-resolve/build/index.js:551:17)
at Object.<anonymous> (node_modules/@vue/test-utils/dist/vue-test-utils.js:5:11)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.004 s
Ran all test suites.
The files that appear in node_modules/vue/dist/
are:
vue.cjs.js
vue.cjs.prod.js
vue.d.ts
vue.esm-browser.js
vue.esm-browser.prod.js
vue.esm-bundler.js
vue.global.js
vue.global.prod.js
vue.runtime.esm-browser.js
vue.runtime.esm-browser.prod.js
vue.runtime.esm-bundler.js
vue.runtime.global.js
vue.runtime.global.prod.js
If I map to another file instead, I get the following error:
Cannot find module 'vue-template-compiler' from 'node_modules/@vue/test-utils/dist/vue-test-utils.js'
Require stack:
node_modules/@vue/test-utils/dist/vue-test-utils.js
test/jest/__tests__/App.spec.js
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)
at Object.<anonymous> (node_modules/@vue/test-utils/dist/vue-test-utils.js:6:27)
In that directory, vue-template-compiler
is not present either.
Expected behavior The test suite should run the tests without configuration errors.
Platform
Quasar Version: 3.0.0-beta.6
@quasar/app Version: 2.0.8
OS: macOS 10.15.7
Node: 12.20.0
NPM: 7.5.0
Yarn: 1.22.10
Additional context I have reproduced this several times from fresh projects.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
moduleNameMapper of Jest config links to files that do not ...
When creating a new project with the Jest test harness (alone or with other harnesses) I run into errors when trying to run...
Read more >Jest moduleNameMapper to find files: "resolver": undefined
Based on the log I guess your configuration is /^components\/(.*)$/: "<rootDir>/src/components$1" which is different from your given code is ...
Read more >Configuring Jest
Thresholds for globs are applied to all files matching the glob. If the file specified by path is not found, an error is...
Read more >Unit Testing
However, there are a few features of the Gatsby build process that mean the standard Jest setup doesn't quite work. This guide shows...
Read more >Configuring package.json · Jest
Jest's configuration can be defined in the package.json file of your ... When using the --config option, the JSON file must not contain...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
was done in https://github.com/quasarframework/quasar-testing/tree/next/packages/unit-jest
Thank you
same issue here.
maybe the issue should be reopened