We are trying to upgrade our test environment from jest 26 to 27. This is our working branch : https://github.com/pass-culture/pass-culture-app-native/tree/update-jest-27
So far, we encounter a bunch of error that we are still unable to fix, for instance:
TypeError: requestAnimationFrame is not a function
TypeError: requestAnimationFrame is not a function
at start (node_modules/react-native/Libraries/Animated/animations/TimingAnimation.js:133:34)
TypeError: global.cancelAnimationFrame is not a function
TypeError: global.cancelAnimationFrame is not a function
at TimingAnimation.stop (node_modules/react-native/Libraries/Animated/animations/TimingAnimation.js:176:12)
Exceeded timeout of 5000 ms for a hook
thrown: "Exceeded timeout of 5000 ms for a hook.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
We have many test failing for this and have found a bunch of proposition but none worked to fix our test
This is the most present error.
If you have any idea, to make progress, it would be welcomed.
Reproduction
- Clone my repo
git clone --single-branch --branche update-jest-27 https://github.com/pass-culture/pass-culture-app-native.git
cd pass-culture-app-native
yarn
yarn test:unit
Additional context
System:
OS: Linux dka 5.8.0-0.bpo.2-amd64 #1 SMP Debian 5.8.10-1~bpo10+1 (2020-09-26) x86_64 GNU/Linux
CPU: (8) arm64
Binaries:
Node: v16.13.2 - /home/dka/.nvm/versions/node/v16.13.2/bin/node
Yarn: 1.22.15 - /home/dka/.yarn/bin/yarn
npmPackages:
jest: 26.0.14 => 27.5.2
react-native: 0.68.2
2
Answers
try add into jestSetup file
I tried to mock
global.cancelAnimationFrame
andglobal.requestAnimationFrame
but none of them worked for me (I’m using react-native).So, I had to mock this module in my
setupFiles.js
to fix the error: