react-testing-library Questions
4
I'm trying to test a login component. Specifically that it redirects on a successful login. It works fine when testing it manually. But in my test it never does the redirect and it can therefor not...
Sewell asked 13/10, 2019 at 11:4
1
Solved
I am using jest with react-testing-library for the most part without issues until I started to move to the screen > getByText/etc way of testing.
Test
describe('test the dashboard when loaded', ...
Ferrotype asked 21/2, 2022 at 10:35
1
Solved
IN the react testing library, I want to get the entire rendered HTML, from the screen and check if this rendered correctly and is present in the dom.
I see that the screen has the methods to query ...
Vaccaro asked 18/2, 2022 at 13:4
3
Solved
I am using Jest and the React testing library to test a component.
I am trying to test a modal and I have a weird issue that I am facing. When I try to get by text the "Modal Title" befor...
Lacee asked 11/3, 2021 at 19:54
5
Currently I'm doing this
getByText(/SomeText/i);
But I want to make a function and pass some text as an argument by first storing it in a variable. I tried doing it like this:
let x = "/SomeT...
Wappes asked 10/11, 2019 at 22:32
2
In short, I'm using Jest, React Testing Library, and Material UI createMuiTheme and everything works except for the tests. They break only when I add the custom theme from my compound theme from cr...
Cowey asked 1/5, 2021 at 3:27
2
I have triggered a change in component using react testing library and I want to check the corresponding change in the state of the component.
Is it possible to check the state of the component
Swick asked 15/5, 2020 at 6:46
8
Solved
I'm in the process of moving over to react-testing-library, and have no idea how to trigger this event and get the results of the changes.
I've tried using the fireEvent function to trigger the c...
Bookstand asked 15/2, 2019 at 0:46
2
Solved
How do I resolve this problem. I am just trying to create a test the ensures that that component renders, but for some reason keep getting this problem even though the component is already inside &...
Damnation asked 21/1, 2022 at 18:21
1
Simply test case: Want to see if a given element is focused.
To check if an element is focused on a react web app with RTL and jest, you have two easy options available to you:
You can check if th...
Brownedoff asked 25/1, 2021 at 18:0
1
Solved
I work on a small App to get familiar with testing and such in React, using jest and React-Testing-Library.
In my <App /> Component, I have a Routes with two Route. One of those looks like th...
Tatiana asked 29/1, 2022 at 11:3
4
Solved
I'm trying to mock a fetch() that retrieves data into a component.
I'm using this as a model for mocking my fetches, but I'm having trouble getting it to work.
I'm getting this error when I run my ...
Kendra asked 12/4, 2019 at 18:58
0
I'm using react-hook-form to control my form inputs (ChakraUI inputs) and disable Submit button in case an input is invalid
Since I have a multipage form I use FormProvider in parent component, cha...
Doolie asked 25/1, 2022 at 16:20
2
Solved
I have a test-suite containing 37 tests that are testing one of my views. Locally, all tests pass without any issues, but when I push my code, the test-suite fails in our pipeline (we are using Git...
Constabulary asked 17/1, 2022 at 13:49
0
I’m running a large test suite with Jest (26.6.2) and react-testing-library (12.1.2) on Node.js (16.3.1).
At some point the test suite sometimes crashes with
FATAL ERROR: CALL_AND_RETRY_LAST Alloca...
Traceable asked 9/1, 2022 at 11:38
2
Solved
await waitFor() makes my test fail but waitFor() makes my test successful (without await).
The official doc said
The async methods return a Promise, so you must always use await or .then(done) whe...
Lumpfish asked 7/1, 2021 at 5:14
1
I have an element that has a combination of static and dynamic text all on the same line.
When testing for this line of text by a substring including some of the static and dynamic text, it fails, ...
Discussant asked 5/1, 2022 at 10:44
1
Solved
I am trying to write a unit test using jest and react testing library. I want to test a function call inside the useEffect hook, but my test is not working. What do I need to do to pass the test su...
Nellanellda asked 4/1, 2022 at 16:10
3
Solved
I've built a simple react application with a searchbar component. The searchbar component contains an Input. For testing Im using Jest with React Testing Library. I want to write a test which tests...
Parmenter asked 16/2, 2021 at 15:1
1
Solved
In my react js application, testing the application using react testing library, i have the next situation. I try to find the data from const d = utils.getAllByTestId('el')[0], and now i want to te...
Balefire asked 23/12, 2021 at 15:8
3
Solved
I have HTML code like so:
<label class="switch" value="true">
<input name="source" type="checkbox"/>
</label>
How can I access input with...
Dinnie asked 8/11, 2021 at 16:25
3
In my React Signup component is a form where the user inputs their email, password, and password confirmation. I am trying to write tests using jest/react-testing-library, however I keep getting a ...
Ledbetter asked 6/11, 2019 at 22:35
3
How can I find the checkbox for by text from span element? I can't modify my HTML.
I wish test fireEvent on input element.
`
<label>
<div>
<input type="checkbox" class=&q...
Chutzpah asked 13/10, 2020 at 14:26
4
I have a really big application with react(lot of pages, modals, tables,etc) and I'm using redux-saga for managing the state. I have a lote of stores and almost in all the components I use the useS...
Greenleaf asked 23/2, 2021 at 21:35
4
Solved
Heres the full error:
Warning: useLayoutEffect does nothing on the server, because its
effect cannot be encoded into the server renderer's output format.
This will lead to a mismatch between the i...
Emalee asked 23/9, 2019 at 22:40
© 2022 - 2024 — McMap. All rights reserved.