4,282 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
1
answer
659
views
Unexpected token 'export' with React 17
I am using Jest with React to write unit test cases for my project with the following specs. When I run yarn test (Jest --coverage). It gives me below error.
Error: Test suite failed to run
Jest ...
0
votes
2
answers
555
views
Jest encountered an unexpected token, In React app
I'm trying to run the test case for the app. But its showing below error. Can someone help me to clear the issue.
Attaching the code repo.
https://github.com/Arun12Muralidharan/team_tracker
I can't ...
2
votes
1
answer
1k
views
TypeError: Cannot destructure property 'config' of 'cacheKeyOptions' as it is undefined
As part of nodejs 18 upgrade, the following versions were upgraded.
"react": "17.0.2",
"react-dom": "17.0.2"
"jest": "29.7.0",
"jest-...
2
votes
1
answer
3k
views
Does Jest automatically restores the real timers after each test case?
Using Jest and Enzyme for testing in React.
For one function inside a react component I am using setTimeOut to change a status.
Now to test that function in jest I am using jest.useFakeTimer.
Using it ...
1
vote
1
answer
2k
views
useEffect trigger when a prop changes cannot be tested
I'm trying to test a react component using jest and enzyme.
There is a useEffect trigger when a prop changes and I am unable to test it properly.
The assertion fails due to undefined value.
This is my ...
0
votes
1
answer
73
views
React (v16.14.0) Testing w/ Enzyme/Jest: Component state rendering data on fetch that is inside a useEffect
I am having issue with testing a component that makes a fetch call inside a useEffect. What's happening is that, state is being updated but the component is not rendering the data from the fetch call ...
0
votes
1
answer
94
views
React Axios API call test with callback
I am facing a issue while testing my api call with callback functions, service not returning promise it give me response in callback function.
Here is my code.
// UserService.js
addUser(paras, ...
-1
votes
1
answer
40
views
How to call const function in functional component react native?
const goToLoginPage = () => {
navigation.navigate(AppConstants.LOGIN_SCREEN)
});
<TouchableOpacity onPress={goToLogin}>
<Text>OK</Text>
</TouchableOpacity>
...
1
vote
0
answers
1k
views
How can I write test cases for FlatList using Jest and Enzyme in a React Native class component?
I'm working on a React Native project and I have a class component that includes a FlatList with TouchableOpacity components. I want to write test cases for this component using Jest and Enzyme to ...
0
votes
0
answers
26
views
Jest + enzyme test for Interval and useefect hook
How to write test cases for below code
const getNews = async (page: number) => {
try {`enter code here`
setLoader(false);
console.log(page, 'page');
const ...
0
votes
1
answer
776
views
How to test if "Downloading..." text is displayed when the loading state is true using Enzyme and Jest?
I have a React component called ChoiceOfFundForm that includes a download button. When the download button is clicked, it triggers the handleClick function, which sets the loading state to true and ...
1
vote
1
answer
320
views
React Testing Library render does not work with react router dom Navigate
I have a component which has a "Navigate" component inside it. I want to test this navigation. But whenever I try to render the component, the test case gets stuck and keeps on running ...
1
vote
0
answers
541
views
How to get coverage of React.lazy import statements when working with react route in react-testing-library?
My test case looks something like this :
In this test case, I've purposefully pushed the route in history object and given component as React.lazy(). Please let me know, what is incorrect here ?
...
-1
votes
1
answer
87
views
Mock import with enzyme testing on react component
I have a react component that needed to be tested,
I am using jest with enzyme for the testing.
The react component imports other functions to operate that need to be mocked.
I am using it just to ...
0
votes
1
answer
148
views
Migrate test case from Enzyme to RTL
We are upgrading our application to React 18 and are in need to migrate our tets from Enzyme to RTL. I am struggling to find a good solution to rewrite my tests:
function useButtonTests(
// eslint-...