We use Jest 28 in our project. When installing jest-chrome, we get the following error:
~> npm i jest-chrome -save-dev --save-exact
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: extension@7.0.0
npm ERR! Found: jest@28.1.0
npm ERR! node_modules/jest
npm ERR! dev jest@"28.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer jest@"^26.0.1 || ^27.0.0" from jest-chrome@0.7.2
npm ERR! node_modules/jest-chrome
npm ERR! dev jest-chrome@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
I tried to install with --force and it passed but then there is another issue.
When I added './jest.setup.js' as the last entry in my setupFilesAfterEnv and the jest.setup.js file like that:
const chromeMock = require('jest-chrome');
Object.assign(global, chromeMock);
console.log(chromeMock);
and I run my tests, it logs an empty object instead of Chrome mock:
console.log
{ chrome: {} }
at Object.<anonymous> (jest.setup.js:5:9)
And tests fail. They expect chrome.storage API but it doesn't exist.
Am I doing something wrong or Jest 28 is not supported yet?
We use Jest 28 in our project. When installing jest-chrome, we get the following error:
I tried to install with
--forceand it passed but then there is another issue.When I added
'./jest.setup.js'as the last entry in mysetupFilesAfterEnvand thejest.setup.jsfile like that:and I run my tests, it logs an empty object instead of Chrome mock:
And tests fail. They expect chrome.storage API but it doesn't exist.
Am I doing something wrong or Jest 28 is not supported yet?