Closed prooli22 closed 4 years ago
I'm sorry but we need actual code to reproduce the bug and debug.
So when trying to reproduce the error in a new project it didn't happened. I noticed that the jest.config.js
file was a bit different and I think this was the problem. So here's its content :
module.exports = {
moduleFileExtensions: [
'js',
'jsx',
'json',
'vue'
],
transform: {
'^.+\\.vue$': 'vue-jest',
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
'^.+\\.jsx?$': 'babel-jest'
},
transformIgnorePatterns: [
'/node_modules/'
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
},
snapshotSerializers: [
'jest-serializer-vue'
],
testMatch: [
'**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
],
testURL: 'http://localhost/',
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname'
]
}
I think it could because of your Jest (or some of the jest-related dependencies') versions.
If I'm not mistaken, @jest/globals
is only used in Jest >25, while Vue CLI generates projects with Jest 24.
Anyway, that's the best guess I can give without seeing the actual code.
a notable change is the 'babel-jest'
in transform. was '<rootDir>/node_modules/babel-jest'
originally. seems some package upgrades require a change of this config.
met the same problem as well, fix inspired by this.
In my case, this was because I had installed jest@^24.1.0
but babel-preset-jest@^26.0.0
.
Same here, but in order to make it work I was forced to bring all three of these libs to the same version: jest
, ts-jest
and babel-jest
.
@Kolobamanacas any idea why jest, ts-jest and babel-jest should be the same version?
@Kolobamanacas any idea why jest, ts-jest and babel-jest should be the same version?
I didn't make any research on this, so unfortunately I don't have a clue.
Version
4.3.1
Environment info
Steps to reproduce
All my tests were working and then after a package update I presume, some of them are not working anymore, because it cannot find the Jest/globals module.
The content of my
tests
folder looks like this :Every tests suites that are not in
components
folder except forstore/store.spec.js
are getting the error.What is expected?
All the tests to work.
What is actually happening?
Some of my tests are not working
I'm guessing that after a package update, some of my tests suites stop working, because the globals of jest are not "injected" in the test file. I've come to this stackoverflow link which is the same result I'm getting, but the answer didn't help me so I'm asking here.
The content of my
jest.config.js
is :I tried :
node_modules
and runnpm install
=> didn't worknpm cache verify
thennpm install
=> didn't workI know my packages are not up to date, but I rolled back to the last commit I add which I knew the tests passed.