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.

jest-expo failed testing createCacheKeyFunction

See original GitHub issue

Summary

Hi, I’m having trouble updating to SDK 42 to run unit tests. I am having this error with jest-expo

Cannot find module 'fbjs-scripts/jest/createCacheKeyFunction'
    Require stack:
    - C:\Users\jocab\WorkSpaceElenas\elenas\app\node_modules\jest-expo\src\preset\assetFileTransformer.js
    - C:\Users\jocab\WorkSpaceElenas\elenas\app\node_modules\@jest\transform\build\ScriptTransformer.js
    - C:\Users\jocab\WorkSpaceElenas\elenas\app\node_modules\@jest\transform\build\index.js
    - C:\Users\jocab\WorkSpaceElenas\elenas\app\node_modules\jest-runtime\build\index.js
    - C:\Users\jocab\WorkSpaceElenas\elenas\app\node_modules\jest-runner\build\testWorker.js
    - C:\Users\jocab\WorkSpaceElenas\elenas\app\node_modules\jest-worker\build\workers\processChild.js

    Require stack:
      node_modules/jest-expo/src/preset/assetFileTransformer.js
      node_modules/@jest/transform/build/ScriptTransformer.js
      node_modules/@jest/transform/build/index.js
      node_modules/jest-runtime/build/index.js
      node_modules/jest-runner/build/testWorker.js
      node_modules/jest-worker/build/workers/processChild.js

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

bare

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

42

Environment

Expo CLI 4.9.1 environment info: System: OS: Windows 10 10.0.19043 Binaries: Node: 14.17.3 - C:\Users\jocab\AppData\Local\Temp\yarn–1627936221009-0.16358276054367216\node.CMD Yarn: 1.22.4 - C:\Users\jocab\AppData\Local\Temp\yarn–1627936221009-0.16358276054367216\yarn.CMD npm: 6.14.13 - C:\Program Files\nodejs\npm.CMD Watchman: 20200424.164118.0 - C:\Users\jocab\watchman\windows\bin\watchman.EXE SDKs: Android SDK: API Levels: 23, 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3 System Images: android-23 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom IDEs: Android Studio: Version 4.2.0.0 AI-202.7660.26.42.7351085 npmPackages: expo: ^42.0.0 => 42.0.0 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.2 => 0.64.2 react-native-web: ~0.13.12 => 0.13.18 Expo Workflow: bare

Reproducible demo or steps to reproduce from a blank project

N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
crcasscommented, Aug 3, 2021

I was able to get around this issue by adding fbjs-scripts under devDependencies in my package.json

npm i fbjs-scripts --save-dev or yarn add fbjs-scripts --dev

I also needed to add @jest/create-cache-key-function under resolutions in my package.json per a reply to this issue

2reactions
byCedriccommented, Aug 3, 2021

This issue happens if you are using a newer React Native version, e.g. 0.64.2. In this React Native version, fbjs-scripts is removed. We will fix this when we upgrade our internal React Native version to 0.64.x. For now, the best workaround would be to use @crcass’s workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@jest/create-cache-key-function - npm
This module creates a function which is used for generating cache keys used by code transformers in Jest.. Latest version: 29.3.1, ...
Read more >
React Native Expo App: How to get it to run Jest tests
Here's the one from my project running Expo's SDK 32: module.exports = function (api) { api.cache(true); ...
Read more >
Testing with Jest - Expo Documentation
In this guide, you'll learn how to set up Jest in your project, write a unit test, write a snapshot test, and common...
Read more >
Configuring Jest
That module can also contain a getCacheKey function to generate a cache key to determine if the logic has changed and any cached...
Read more >
Troubleshooting | React Navigation
Sometimes it might even be due to a corrupt installation. If clearing cache didn't work, try deleting your node_modules folder and run npm...
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