TypeError: batch is not a function in Jest
See original GitHub issue TypeError: batch is not a function
at Object.batch [as notify] (node_modules/react-redux/lib/utils/Subscription.js:29:7)
at Subscription.notify [as notifyNestedSubs] (node_modules/react-redux/lib/utils/Subscription.js:71:20)
at notifyNestedSubs (node_modules/react-redux/lib/components/connectAdvanced.js:272:13)
at checkForUpdates (node_modules/react-redux/lib/components/connectAdvanced.js:296:9)
at create (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:10867:26)
at commitHookEffectList (node_modules/react-test-renderer/cjs/react-test-renderer.develo
Versions
"react": "^16.9.0",
"react-native": "0.60.5",
"react-redux": "7.0.0",
"redux": "^4.0.0",
"redux-persist": "^5.10.0",
Once I updated to 7.0, this problem appears in all test cases using react-redux.
When I go into node_modules/react-redux/lib/utils/Subscription.js
and change line
var batch = (0, _batch.getBatch)(); to var batch = (0, _batch.getBatch);
it works fine
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
TypeError: this.dynamodb.batchGetItem is not a function with jest
You can use jest.spyOn(object, methodName) to mock AWS.DynamoDB class and its instance. Use mockFn.mockReturnThis() to mock method chain ...
Read more >jest.Mock.mockImplementation JavaScript and Node.js code ...
Accepts a function that should be used as the implementation of the mock. The mock itself will still record all calls that go...
Read more >batch | React Redux
If you're using React 18, you do not need to use the batch API. React 18 automatically batches all state updates, no matter...
Read more >How to mock function of module - Medium
Way3: use jest.mock to mock specific module function ... const module = jest. ... TimeCop is not working when using Shared_examples.
Read more >Expect a function to throw an exception in Jest - eloquent code
Unit testing functions in JavaScript using Jest sometimes requires checking if an ... We can also assert that an error is not thrown...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Was able to temporarily get around the issue with this.
In case it helps anyone, here is how I’ve attempted to implement
unstable_batchedUpdates
for my React custom renderer without creating a dependency upon React DOM or React Native. It’s undocumented, so I have no idea.My app is now freezing at run-time post state update, rather than crashing at startup, so I think it’s at least a step in the right direction. And the latter part about freezing may not even be related.
EDIT: My methodology seems to be exactly the same as that used by
react-three
, so I can at least have some confidence in advising it.