Build test with Jest fails with `Could not locate module @/something`
See original GitHub issueI’m building an app with vuejs and testing with jest and running the tests locally works, but on circleci fails with the error
FAIL test/unit/specs/components/ui/MessageUI.spec.js
Test suite failed to run
Configuration error:
Could not locate module @/components/ui/MessageUi (mapped as /home/circleci/repo/src/components/ui/MessageUi)
Please check:
"moduleNameMapper": {
"/^@\/(.*)$/": "/home/circleci/repo/src/$1"
},
"resolver": undefined
is not finding the component with the alias @. 😠
the failing component require:
import Component from '@/components/ui/MessageUi'
in the same folder I have another test, working, with:
import Component from '@/components/ui/TabsUi'
build: #39 repo: poc-cms test: MessageUI.spec.js#L3 component MessageUI.vue jest config for the @ alias : jest.conf.js#L11
the closest issue related, on jest: https://github.com/facebook/jest/issues/1290
Issue Analytics
- State:
- Created 6 years ago
- Comments:17 (2 by maintainers)
Top Results From Across the Web
vue.js - Jest error Could not locate module .... mapped as
For me I did not finish reading the Jest docs and thought that <rootDir> was some sort of placeholder for my root directory...
Read more >Build test with Jest fails with `Could not locate module ...
I'm building an app with vuejs and testing with jest and running the tests locally works, but on circleci fails with the error...
Read more >Angular >=13 | jest-preset-angular - GitHub Pages
Jest ESM support with Angular 13 is new and may have issues. ... Cannot find modules error when importing any deep paths from...
Read more >Configuring Jest
All modules used in your tests will have a replacement implementation, ... If the file specified by path is not found, an error...
Read more >test suite failed to run cannot find module jest - You.com
I used Create React App to make a new project, and now i try to implement each feature i will need. I am...
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
We faced the same issue which surprisingly passed on Windows and not on Linux (or circleci).
It turned out to be a simple file-name case sensitivity. The component’s filename was by mistake
componentName
rather thanComponentName
.changing the
moduleNameMapper
on jest.conf.js to remove thesrc
breaks all testsfrom
to