-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: expect.extend is not a function #3215
Comments
Hey! 👋 The issue doesn't seem to contain a minimal reproduction. Could you provide a snippet of code, a snack or a link to a GitHub repository that reproduces the problem? |
Hey! 👋 It looks like you've omitted a few important sections from the issue template. Please complete Description, Snack or minimal code example, Package versions and Affected platforms sections. |
This happens on jest upgrade from ^27.5.1 → ^28.0.3 |
To fix this:
I have opened a PR to fix this here: #3217 |
i've tried the same thing you did, but it still shows me the same error |
same error, i believe this resolve this error when merge, |
## Description Fixes for Jest 28 compatability (Issue #3215) ## Changes - Change the import for expect to maintain compatability with Jest 28. - Updated the documentation to ensure the enviornment is set up before running the script. ## Checklist - [x] Included code example that can be used to test this change - [x] Updated TS types - [x] Added TS types tests - [x] Added unit / integration tests - [x] Updated documentation - [x] Ensured that CI passes
the PR is merged, but i still facing the same error
|
@matt-oakes When I try to run it in my private repo with jest ~26 it blows up:
|
still erroring!!!!!! |
It's not missing a repo. I provided a minimal example repro that reproduce the issue. |
pretty simple repo. I just added
|
The try/catch is around the wrong things. The fix is: Go into
|
Patch file
|
Also, for RV 0.69+hermes has moved to c++17 and it needs to be modified:
Change to:
|
@billnbell thank you very much for sharing your fix for the issue 🙌 (will try it later this week) @billnbell github-actions seems to think that there still are missing a repo - does it have to be you that add it? If so you can perhaps fork mine or link to it? |
@billnbell is it too much to ask if you could make a PR to show the fix to the demo repo I have provided? |
Here's the fix #3559 |
This does not require a repo. Install React Native 0.70 and create a simple jest test, and it blows up. The fixes provided above work well. |
Tried to open the PR, copy the content from the file changed into the my node_modules/react-native-reanimated2 and do a There still seems to be some issues regarding
|
Fwiw, I had to use the following, but it is working for me now:
|
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? |
I fixed the before this.timeProvider = { now: () => global.ReanimatedDataMock.now() }; after this.timeProvider = { now: () => global.performance.now() }; Not sure if this is the right way to go or if it actually fixes the issue, but I'm not getting any more TypeErrors at least. |
not work for me |
any one fix this error ? |
fixed by doing that |
## Description Reanimated is not fully compatible with Jest 28+ even after the PR #3347. Using it with Jest 28+ leads to this error: <img width="796" alt="Ekran Resmi 2022-09-10 15 00 33" src="https://user-images.githubusercontent.com/22980987/189482337-cc2655f6-9463-4a05-9998-5fc3592f5cc0.png"> The reason is, the "expect" module's export approach has changed starting from Jest 28. It used to export the `expect` function directly, as can be seen [here](https://github.com/facebook/jest/blob/v27.5.1/packages/expect/src/index.ts#L441). This means, requiring the "expect" module like this ```ts const expect = require('expect') ``` was providing direct access to the `expect` function alongside with its attached methods, like `extend`. This has [changed with Jest 28](https://github.com/facebook/jest/blob/v28.0.0/packages/expect/src/index.ts#L449). `export default expect` is the new export statement, which means requiring the "expect" package returns the module object, instead of the function. #3347 PR attempts to fix this error by assuming "expect" package should throw an error with Jest 28 and it can catch that and require the "expect" from the `@jest/globals` package for Jest 28+ project but it's not the case in reality. "expect" package is still shipped with Jest 28, so, requiring it doesn't throw an error as expected in the PR. By knowing the export difference, I checked if the value of the module is object or not after requiring it. If it's an object, it means user is on Jest 28+ codebase. The rest is the same with the previous PR. I require the "expect" function from `@jest/globals` and use it. Tested on Jest 29 and Jest 27.5.1 Fixes #3553 and #3215.
## Description Reanimated is not fully compatible with Jest 28+ even after the PR #3347. Using it with Jest 28+ leads to this error: <img width="796" alt="Ekran Resmi 2022-09-10 15 00 33" src="https://user-images.githubusercontent.com/22980987/189482337-cc2655f6-9463-4a05-9998-5fc3592f5cc0.png"> The reason is, the "expect" module's export approach has changed starting from Jest 28. It used to export the `expect` function directly, as can be seen [here](https://github.com/facebook/jest/blob/v27.5.1/packages/expect/src/index.ts#L441). This means, requiring the "expect" module like this ```ts const expect = require('expect') ``` was providing direct access to the `expect` function alongside with its attached methods, like `extend`. This has [changed with Jest 28](https://github.com/facebook/jest/blob/v28.0.0/packages/expect/src/index.ts#L449). `export default expect` is the new export statement, which means requiring the "expect" package returns the module object, instead of the function. #3347 PR attempts to fix this error by assuming "expect" package should throw an error with Jest 28 and it can catch that and require the "expect" from the `@jest/globals` package for Jest 28+ project but it's not the case in reality. "expect" package is still shipped with Jest 28, so, requiring it doesn't throw an error as expected in the PR. By knowing the export difference, I checked if the value of the module is object or not after requiring it. If it's an object, it means user is on Jest 28+ codebase. The rest is the same with the previous PR. I require the "expect" function from `@jest/globals` and use it. Tested on Jest 29 and Jest 27.5.1 Fixes #3553 and #3215.
…n#3559) Reanimated is not fully compatible with Jest 28+ even after the PR software-mansion#3347. Using it with Jest 28+ leads to this error: <img width="796" alt="Ekran Resmi 2022-09-10 15 00 33" src="https://user-images.githubusercontent.com/22980987/189482337-cc2655f6-9463-4a05-9998-5fc3592f5cc0.png"> The reason is, the "expect" module's export approach has changed starting from Jest 28. It used to export the `expect` function directly, as can be seen [here](https://github.com/facebook/jest/blob/v27.5.1/packages/expect/src/index.ts#L441). This means, requiring the "expect" module like this ```ts const expect = require('expect') ``` was providing direct access to the `expect` function alongside with its attached methods, like `extend`. This has [changed with Jest 28](https://github.com/facebook/jest/blob/v28.0.0/packages/expect/src/index.ts#L449). `export default expect` is the new export statement, which means requiring the "expect" package returns the module object, instead of the function. software-mansion#3347 PR attempts to fix this error by assuming "expect" package should throw an error with Jest 28 and it can catch that and require the "expect" from the `@jest/globals` package for Jest 28+ project but it's not the case in reality. "expect" package is still shipped with Jest 28, so, requiring it doesn't throw an error as expected in the PR. By knowing the export difference, I checked if the value of the module is object or not after requiring it. If it's an object, it means user is on Jest 28+ codebase. The rest is the same with the previous PR. I require the "expect" function from `@jest/globals` and use it. Tested on Jest 29 and Jest 27.5.1 Fixes software-mansion#3553 and software-mansion#3215.
* Preliminary version of linear progress * Finalized Linear Progress * Finalized LinearProgress + restrcuture to allow support for indetermintie progress * Fixed indeterminte mode of linear progress * Added circular progress component * Updated variable name * Fixed SectionList test to use '@testing-library/jest-native' * Setup tests for progress indicators - reanimated requires some extra steps to work in jest * Added test for LinearProgress * Finalized tests for progress indicators * Patched rn-reanimted to fix broken tests: software-mansion/react-native-reanimated#3215 * Updated testing config to allow expo in tests
…n#3559) ## Description Reanimated is not fully compatible with Jest 28+ even after the PR software-mansion#3347. Using it with Jest 28+ leads to this error: <img width="796" alt="Ekran Resmi 2022-09-10 15 00 33" src="https://user-images.githubusercontent.com/22980987/189482337-cc2655f6-9463-4a05-9998-5fc3592f5cc0.png"> The reason is, the "expect" module's export approach has changed starting from Jest 28. It used to export the `expect` function directly, as can be seen [here](https://github.com/facebook/jest/blob/v27.5.1/packages/expect/src/index.ts#L441). This means, requiring the "expect" module like this ```ts const expect = require('expect') ``` was providing direct access to the `expect` function alongside with its attached methods, like `extend`. This has [changed with Jest 28](https://github.com/facebook/jest/blob/v28.0.0/packages/expect/src/index.ts#L449). `export default expect` is the new export statement, which means requiring the "expect" package returns the module object, instead of the function. software-mansion#3347 PR attempts to fix this error by assuming "expect" package should throw an error with Jest 28 and it can catch that and require the "expect" from the `@jest/globals` package for Jest 28+ project but it's not the case in reality. "expect" package is still shipped with Jest 28, so, requiring it doesn't throw an error as expected in the PR. By knowing the export difference, I checked if the value of the module is object or not after requiring it. If it's an object, it means user is on Jest 28+ codebase. The rest is the same with the previous PR. I require the "expect" function from `@jest/globals` and use it. Tested on Jest 29 and Jest 27.5.1 Fixes software-mansion#3553 and software-mansion#3215.
Closing since fix is already merged: #3559 |
Latest RN 2.8.0 "react-native-reanimated": "2.8.0".
Getting:
FAIL src/tests/ComponentRender-test.tsx
● Test suite failed to run
The text was updated successfully, but these errors were encountered: