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.

[BUG] @snowpack/app-scripts-react is not compatible with Jest 27.

See original GitHub issue

Bug Report Quick Checklist

  • I am on the latest version of Snowpack & all plugins.
  • I use package manager yarn
  • I run Snowpack on OS Mac
  • I run Snowpack on Node.js v12+

Describe the bug

@snowpack/app-scripts-react is not compatible with Jest 27.

TypeError: Cannot destructure property 'config' of 'cacheKeyOptions' as it is undefined.
    at Object.getCacheKey (/Users/piotr/[...]/node_modules/@snowpack/app-scripts-react/node_modules/babel-jest/build/index.js:217:14)
    at ScriptTransformer._getCacheKey (/Users/piotr/[...]/node_modules/@jest/transform/build/ScriptTransformer.js:280:41)
    at ScriptTransformer._getFileCachePath (/Users/piotr/[...]/node_modules/@jest/transform/build/ScriptTransformer.js:351:27)
    at ScriptTransformer.transformSource (/Users/piotr/[...]/node_modules/@jest/transform/build/ScriptTransformer.js:588:32)
    at revertHook.exts (/Users/piotr/[...]/node_modules/@jest/transform/build/ScriptTransformer.js:864:18)
    at Module._compile (/Users/piotr/[...]/node_modules/pirates/lib/index.js:93:29)
    at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Object.newLoader (/Users/piotr/[...]/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)

Looks like the babel-jest dependency should be updated to 27.

Expected behavior

Tests cases should be executed.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:16
  • Comments:9

github_iconTop GitHub Comments

2reactions
chphillipvosecommented, Jul 27, 2021

So I’ve forked locally to figure out a fix, and the package needs a couple of changes to work. The package.json file needs babel-jest updating to v27.x as per @pusewicz 's suggestion. But it also needs the createTransformer method updating (as per this issue in the Jest repo https://github.com/facebook/jest/issues/11444) which would look something like this:

packages/app-scripts-react/jest/babelTransform.js

// @remove-file-on-eject
/**
 * Copyright (c) 2014-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
'use strict'

const babelJestMd = require('babel-jest')
const importMetaBabelPlugin = require('./importMetaBabelPlugin')

const babelJest = babelJestMd.__esModule ? babelJestMd.default : babelJestMd

module.exports = babelJest.createTransformer({
  presets: ['babel-preset-react-app', '@babel/preset-react', '@babel/preset-typescript'],
  plugins: [[importMetaBabelPlugin]],
})
2reactions
RobertLowecommented, Jun 5, 2021

This is the correct fix, jest and babel-jest should follow the same major, ex 27.x.x

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] @snowpack/app-scripts-react is not compatible with ...
Describe the bug. @snowpack/app-scripts-react is not compatible with Jest 27. TypeError: Cannot destructure property 'config' of ' ...
Read more >
Jest 27: New Defaults for Jest, 2021 edition
It has amassed well above a hundred comments, not even taking into ... we are now confident that jest-circus is highly compatible with ......
Read more >
@testing-library/jest-dom - npm
This allows you to check whether an element is not disabled from the user's perspective. It works like not.toBeDisabled() . Use this matcher...
Read more >
How To Fix Unexpected Token Error for NPM Package in react ...
Are you getting this error with react -leaflet or other packages. If you are then it's most likely related to babel and there...
Read more >
React typescript snowpack - can't import .webp - Stack Overflow
It looks very promising but I get an error [@snowpack/plugin-typescript] Cannot find module '../../dummy.webp or its corresponding type ...
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