react-native-reanimated
react-native-reanimated copied to clipboard
Won't build Jest issue
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
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?
My code above works. The try/catch hack is not good that was added to try to fix this before.
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);
I created a PR that fixes this issue https://github.com/software-mansion/react-native-reanimated/pull/3559
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 ?