react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

Won't build Jest issue

Open billnbell opened this issue 3 years ago • 4 comments

Description

Jest still will not build right.

 export const setUpTests = (userConfig = {}) => {
-    const expect = require('expect');
+    const { expect } = require('@jest/globals');
     require('setimmediate');

You added a try / catch around require('expect'); but this does not help me, since I have expect loaded.

Steps to reproduce

Use SetUpTests() for Jest.

Snack or a link to a repository

none

Reanimated version

2.10.0

React Native version

0.70.0

Platforms

iOS

JavaScript runtime

No response

Workflow

No response

Architecture

No response

Build type

No response

Device

No response

Device model

No response

Acknowledgements

Yes

billnbell avatar Sep 07 '22 07:09 billnbell

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

github-actions[bot] avatar Sep 07 '22 07:09 github-actions[bot]

My code above works. The try/catch hack is not good that was added to try to fix this before.

billnbell avatar Sep 07 '22 07:09 billnbell

Hi, indeed it does not work well... So therefore here is my patch for us running 0.70

diff --git a/node_modules/react-native-reanimated/lib/reanimated2/jestUtils.js b/node_modules/react-native-reanimated/lib/reanimated2/jestUtils.js
index d8befd8..bbadce9 100644
--- a/node_modules/react-native-reanimated/lib/reanimated2/jestUtils.js
+++ b/node_modules/react-native-reanimated/lib/reanimated2/jestUtils.js
@@ -146,14 +146,14 @@ export const advanceAnimationByFrame = (count) => {
 };
 export const setUpTests = (userConfig = {}) => {
     let expect;
-    try {
-        expect = require('expect');
-    }
-    catch (_) {
-        // for Jest in version 28+
-        const { expect: expectModule } = require('@jest/globals');
-        expect = expectModule;
-    }
+    const { expect: expectModule } = require('@jest/globals');
+    expect = expectModule;
+    // try {
+    //     expect = require('expect');
+    // }
+    // catch (_) {
+    //     // for Jest in version 28+
+    // }
     require('setimmediate');
     frameTime = Math.round(1000 / config.fps);
     config = Object.assign(Object.assign({}, config), userConfig);

Cmoen11 avatar Sep 09 '22 07:09 Cmoen11

I created a PR that fixes this issue https://github.com/software-mansion/react-native-reanimated/pull/3559

yusufyildirim avatar Sep 10 '22 12:09 yusufyildirim

I don't like bumping threads but this is blocking my team on keeping our Jest depedencies up to date. Just wondering about the progress on this as there has been a working fix for this in a PR up for over a month now, just hoping for an ETA on the review for it on #3559 ?

backlands avatar Oct 26 '22 14:10 backlands