testing-library Questions
3
Solved
I'm learning testing on react and react components with react testing library and jest. While trying to test a component that works when rendering the component it works with no issue, but when tes...
Lauretta asked 28/1, 2023 at 20:29
2
Solved
I have a component that I am using in React Router v6 for managing private routes, that does some checks on an auth token, and will either render the Outlet component or will redirect to a login pa...
Foy asked 10/1, 2022 at 15:30
1
I'm getting this error when testing a component that uses react query custom hook:
" No QueryClient set, use QueryClientProvider to set one "
this is my hook:
export default () => {
c...
Firstrate asked 2/3, 2022 at 8:43
2
What could cause "Unable to find a label with the text of" for an element that is present?
What could cause getByLabelText from testing-library to report that it can't find an element when the element is definitely there? The exact error I'm getting is
TestingLibraryElementError: Unable...
Bagasse asked 4/3, 2022 at 19:41
3
I have this Vitest test:
import React from 'react';
import { expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { StyledNativeTimePicker } from
'....
Hyperemia asked 6/12, 2023 at 9:44
1
Solved
I'd like to do some integration testing of my svelte + page.js-based router using vitest, but I'm running into an issue where the jsdom instance only updates correctly once per test file.
In the fo...
Expiate asked 27/11, 2022 at 11:33
3
I write a test for a seletion and I get this warning. In my test I'm waiting for the end of the act. Why I get this error?
Warning: You seem to have overlapping act() calls, this is not supported....
Cardoso asked 30/1, 2022 at 13:9
14
Solved
I have a component library that I'm writing unit tests for using Jest and react-testing-library. Based on certain props or events I want to verify that certain elements aren't being rendered.
getB...
Fadiman asked 12/10, 2018 at 15:59
2
My react component renders a <script> tag using nextJS Head. When trying to query the element with testing-libary's getByTestId method and I get the message below:
TestingLibraryElementError:...
Acervate asked 15/7, 2021 at 11:47
3
Solved
I am working on a react app using mainly functional components. This is all tested with the react - testing library. I would like to test the focus of some elements to show that after some interact...
Dagda asked 20/10, 2022 at 8:24
1
In a test suite that needs to call userEvent.setup() in multiple tests, sometimes I'll do the userEvent.setup() in a beforeEach and then just reference the same user var in multiple tests
let user:...
Salangi asked 2/12, 2022 at 17:35
2
I want to assert on a condition which I know will not be true immediately, but might be true after an async action, in which the test should fail.
Say I'm testing this counter component:
function C...
Klotz asked 24/6, 2021 at 15:48
2
I have started using Next.js in my newest project and I would like to implement some tests for the pages.
I have created a _document file where I set up all of the meta tags which I want to use, in...
Jazzman asked 9/6, 2020 at 7:46
2
React Testing Library does not apply sx props of Material UI components during rendering.
For example, I specify properties to hide an element at certain breakpoints.
<>
<AppBar
data-tes...
Ballonet asked 22/2, 2022 at 8:3
2
Im wondering if putting new class name into html component only for readability and tests is ok.
Let's say we have this situation:
class ComponentOne extends React.Component {
render(){
<div&...
Particularism asked 11/7, 2021 at 20:52
1
Problem: UserEvent.type is not working. I have a simple test where I get the textbox, which works, but when trying to type in that textbox, the text does not display.
Most of the solutions I have s...
Portsalut asked 21/7, 2022 at 19:37
2
Solved
I need to test that a react component is called with opened={true} prop after an button click is fired. I am using testing-library ( testing-library/react + testing-library/jest-dom).
I mocked the ...
Woadwaxen asked 18/11, 2021 at 11:46
2
Solved
I am new to Vue and followed the recommendation to use vue testing library. The only issue is I can't seem to find a way to inject my code into globalProperties in render function.
Does anyone know...
Steradian asked 30/7, 2021 at 1:37
2
Solved
I am trying to write a few simple tests that the headers and data I want to render are showing up as expected. I created a repo - https://github.com/olore/ag-grid-testing-library to reproduce. The ...
Leech asked 19/9, 2020 at 14:28
1
in react testing library, as per the conventions, it is better to use screen than to destructure the methods from render.
I have a component, where I need to test the text that is rendered. The top...
Kirby asked 6/2, 2022 at 18:39
1
We have noticed that our unit tests are performing very slowly and the culprit seems to be getByRole for querying for button elements etc. Here is an example of a query that was giving us problems ...
Sibelius asked 25/10, 2021 at 16:47
2
Solved
I have multiple buttons in my component and all of them should be disabled.
const buttons = screen.getAllByRole('button');
expect(ALL BUTTONS).toHaveAttribute('disabled'); // I want something like...
Markson asked 23/10, 2021 at 3:26
1
Solved
I am using React and writing a Modal component like so:
const MyModal: FC<MyModalProps> = memo((props) => {
return (
<Modal isOpen={true} data-client-id={modal-client-id}>
...
&l...
Barye asked 19/9, 2021 at 4:44
1
Solved
here is my code example
<div class="dropdown" data-testid="dropdown">
<div class="option" data-testid="option">
<b>[AF]</b> Afghani...
Marseilles asked 1/7, 2021 at 11:39
1
When testing svelte components, using jest & @testing-library/svelte, the state is shared between tests, is there away to tear down after each test so i have more isolated unit tests.
store/...
Madaih asked 1/4, 2020 at 12:40
1 Next >
© 2022 - 2025 — McMap. All rights reserved.