Questions tagged [react-testing]
116 questions
1
vote
1 answer
React testing library - Property 'value' does not exist on type 'HTMLElement'
I have a super simple form I'm trying to test with react testing library
The form is like
import React, { useState } from 'react';
import './App.css';
function App() {
const [email, setEmail] = useState('')
const [password, setPassword] =…

lomine
- 873
- 5
- 20
- 36
1
vote
3 answers
How can I test a popover from chakra-ui
I need to test a popover from chakra-ui in a React App.
I tried with this. But It does not find the popover. If I try by text, then I cannot assert if it is visible.
it('show a popover when hover terms and conditions', () => {
…

Alex Javier Ulloa
- 23
- 5
1
vote
0 answers
React testing library can't find element after click
I enter password and username wrongly on the application and I get an alert. But when I try to test this I can't find the element after click action. I tried to use waitfor to wait for the dom to rerender ( does it do this? I understood so). I used…

FaFa
- 358
- 2
- 16
1
vote
0 answers
Unit testing react child components that are connected from a redux-form to increase test coverage
I have a simple React component that used FieldArray from 'redux-form' library and I am having a hard time increasing the test coverage for the component. When I console log the component, I get a ConnectedFieldArray component but not entirely sure…

Brr Switch
- 974
- 1
- 9
- 21
1
vote
1 answer
Triggering react tests inside docker containers
I have container with React application which is running from docker-compose.
When I print logs for this container using
docker-compose logs -f
There is a message:
PASS src/App.test.js
✓ renders learn react link (28 ms)
tests_1 |
Test Suites: 1…

Krzysztof
- 33
- 3
1
vote
1 answer
React Jest & React Testing Library, Writing test for Video player (play and pause)
I am using as part of my project, it gives you in HTML
I want to write the test cases for this.
To write test case, without using autoPlay I play the video manually so I have to write a test case for play and pause event of…

Enigmatic
- 602
- 1
- 8
- 19
1
vote
1 answer
Getting error while adding React Testing Library for create-react-app (version 16.12.0)
I'm working on a react project in typescript (react version 16.12.0) and I would like to add React Testing Library to this. The newer versions of react comes with React-Testing-Library but the project I'm working on doesn't come with RTL, so I…

Sandeep Amarnath
- 5,463
- 3
- 33
- 43
1
vote
1 answer
How to mock useselector with shallowequal in Jest
I having this component
const Testcomponent = (props:any) => { const {
name,
age } = useSelector(
(state: any) => ({
name: state.user.name,
age: state.user.age
}),
shallowEqual );
return…

Arun Lazer
- 33
- 5
1
vote
0 answers
How to create a event of type React.FormEvent React Typescript for tests
I have a question about react with tyescript, since as a learning method, I decided to migrate an application made in JavaScript to Typescript, when I got to the tests things got a bit complicated, and if it is not an error, tests pass but my syntax…

Caquita1414
- 13
- 3
1
vote
1 answer
and React.createElement
In .tsx, this works as expected:
const LazyComponent = lazy(() => import("path-to-my-lazy-component"));
const SuspenseComponentTSX = (
Loading
}>

user6118986
- 341
- 2
- 15
1
vote
0 answers
Best way to mock multiple return values for imported util/hook with Jest?
I'm trying to figure out the best way to mock different return values for a custom hook that's being utilized by one of my components. Not my component/hook but to illustrate:
/hooks/useCount.js
export function useCount() {
// does something to…

warrenbuffering
- 242
- 4
- 24
1
vote
0 answers
OnGridReady enzyme test results in "TypeError: Cannot read property 'dispatchEvent' of null" for ag-grid React testing
I am facing an error TypeError: Cannot read property 'dispatchEvent' of null when trying to run an enzyme test to simulate onGridReady of an ag-grid table.
My questions and places where I am getting stuck...
How do I gracefully test the onGridReady…

beedeegeezz
- 29
- 6
1
vote
2 answers
Why the req.url.searchParams parameters object is empty when I test two get requests using Mock Service Worker?
I have a test in a react app that uses Mock Service Worker. I setup the server like this:
const server = setupServer(
// https://api.github.com/search/users?q=${userName}&type=users&per_page=10&page=${pageNo}`,
…

Efthyvoulos Tsouderos
- 87
- 2
- 8
1
vote
1 answer
react testing library assert dropdown options are rendered in correct order
I'm trying to test a dropdown component rendering certain options in the correct order.
Currently the test-code looks like:
const dropdown = getByTestId('my-dropdown');
const selectOptions = dropdown.ownerDocument.querySelectorAll(
'.Select-menu…

Seneca
- 2,392
- 2
- 18
- 33
1
vote
0 answers
React testing library - external web component callback function is not working
i am currently using a external web component library on my react application. The library has custom button and other components.
The Button component has its own custom callback function, which i am using in my code.
While writing my test case…

Ashwin Allen
- 99
- 1
- 6