question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Describe the bug I am trying to use jest-playwright with Jest 27 and get this error:

TypeError: virtualMocks.get is not a function

      at Resolver._getVirtualMockPath (../../node_modules/jest-resolve/build/index.js:447:25)

To Reproduce I am using a standard installation and a single simple test that just opens a browser.

Desktop (please complete the following information):

  • OS: [macOS M1]
  • Playwright version [1.10.0]
  • jest-playwright version [1.5.1]
  • jest version [27.0.0-next.7]

Jest configuration (Either in the package.json > jest or in the jest.config.js):

module.exports = {
   globals: {
       "ts-jest": {
           diagnostics: false,
           isolatedModules: true,
       },
   },
   moduleDirectories: ["<rootDir>/../../node_modules"],
   moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
   moduleNameMapper: {
       "\\.css$": "identity-obj-proxy",
       "\\.scss$": "identity-obj-proxy",
       "^@cling/(.*)$": "<rootDir>/../$1",
   },
   reporters: ["default"],
   setupFilesAfterEnv: ["<rootDir>/../lib.shared.test/jest_setup.ts"],
   snapshotSerializers: [],
   preset: "jest-playwright-preset",
   testMatch: ["<rootDir>/__tests__/**/*.spec.ts?(x)"],
   transform: {"^.+\\.tsx?$": "ts-jest"},
}

This is a sub-project in a monorepo. But even if I use jest-playwright-preset in the main configuration it won’t work.

Additional context All’s working fine with Jest 26.6.3

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
lourdcommented, Dec 1, 2021

I just ran into this in my project that uses a monorepo. The root issue ended up being an indirect dependency on Jest v26 through react-scripts. No idea why! ¯\(ツ)/¯ I resolved the issue by specifying a resolution with yarn to the same one I was already depending on. E.g.:

...
"resolutions": {
  "react-scripts/jest": "27.2.3"
},
...

Be sure to clear out your node_modules and reinstall after doing so!

4reactions
amrsalem1commented, Oct 29, 2021

what was the resolution of this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest 27: New Defaults for Jest, 2021 edition
We dropped support for Node 13—but Jest always supports the Current and all LTS Node versions, and Jest 27 continues to support Node...
Read more >
Add support for Jest 27 · Issue #2611 · kulshekhar/ts-jest
Upgrading to Jest 27 leads to the following error: TypeError: Jest: a transform must export something. Also the peer dependency scope should be ......
Read more >
Stencil: Jest 27 Upgrade Instructions - Ionic Blog
Stencil v2.13.0 includes support for Jest v27, but does not require any project to upgrade their version of Jest at this time. You...
Read more >
jest - npm
Delightful JavaScript Testing.. Latest version: 29.3.1, last published: 2 months ago. Start using jest in your project by running `npm i ...
Read more >
Jest v27 support
Jest v27 support. 26 May 2021 1 min read. The next major version of Jest was released on May 25, 2021 . The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found