Skip to content

Jest 28 support #17

@kamil-cf

Description

@kamil-cf

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions