3,736 questions
0 votes
0 answers
63 views
Unable to find element text from Backstage Table component in test (All components (2) not found)
I'm testing a Backstage plugin component that renders a list of Ansible components using the Backstage Table from @backstage/core-components. In my test, I mock the catalog API to return 2 entities (...
0 votes
1 answer
80 views
testing an useState change inside a callback
I have a component like this to test: import {doSomethingMocked} form 'mockedLibrary'; const TheComponent = (props) => { const [isToTest, setIsToTest] = useState(false); const handleClick = ...
-1 votes
2 answers
582 views
Next.js and Jest: TypeError `the "original" argument must be of type function`
I am new to Next.js but not to React and Jest; this is the first test suite I'm setting up in Next.js. I have the following (extremely minimal, but this example does cause the error) component I am ...
-1 votes
1 answer
555 views
Test failure after upgrading to React Router v7.6.2
I am experiencing an issue after upgrading to React-Router version 7.6.2. I was able to replicate the failure: StackBlitz. Note that this test passed when I had v6 of React-Router-DOM. The problem ...
0 votes
1 answer
195 views
Vitest react wait for function in useCallback to be in ready state
I have the following hook: function useWelcomeMessage() { const { data, error} = useGetWelcomeMessage(); const printMessage = useCallback(async () => { if (data) { alert(data) ...
0 votes
1 answer
32 views
How to Assert the Absence of an Element After an Async API Response in Testing Library
I'm wondering if it's better to use findBy together with rejects.toThrow instead of using queryBy with not.toBeInTheDocument when checking that an element is not displayed in cases like the following. ...
0 votes
1 answer
45 views
Testing library throws error with finding input element with slight change
I am testing my Input element by 2 way. adding value and click on button to "todo list" works fine adding value and enter the "input' field, but throws error. I am seeking ...
1 vote
1 answer
147 views
React 19 'use', NextJS 15 async params and React testing-library
Using NextJS 14 and react testing-library, we previously used to test client components and client-only pages that take dynamic URL parameters like this: type PageProps = { params: { date: string }...
1 vote
0 answers
91 views
What exactly are the conditions that React will give the act warning?
I know that this is a well trodden topic, but most of the articles and help topics on this talk about how to avoid, and don't actually detail what exactly causes it. I have a simple example of how we ...
0 votes
0 answers
91 views
Vitest: TypeError: Unknown file extension ".woff" in package from React TS project with vitest
I am trying to set up unit tests for a frontend project. Currently, i am trying to use vitest, since we use vite as well. Additionally i am going with HappyDom and TestingLibrary. Now, i am facing a ...
0 votes
1 answer
197 views
How can one test Chakra v3 UI Select in NextJS with Jest?
I'm building a NextJS (react) app with Chakra UI (version 3). I'd like to write unit tests, but I don't know to handle the way Chakra UI v3 handles select. Here's a sample test app: 'use client'; ...
0 votes
0 answers
125 views
How do i test Lexical Toolbar Plugin and trigger onError of initialConfig?
I am using ToolbarPlugin from Lexical and using the code from Lexical repo. My Sonarqube has flagged below code for test coverage and am not sure what test needs to be inlcuded: `const $updateToolbar =...
0 votes
0 answers
39 views
When using react-query, how to write unit tests for the scenario of Dependent Queries?
how to write unit tests for useUpdateTodo hook without mock useGetUserId // Get the user const useGetUserId = ()=>{ const { data: user } = useQuery({ queryKey: ['user', email], queryFn: ...
1 vote
1 answer
89 views
Can't successfully test a custom hook using useState and useEffect
While learning React, I'm trying to understand custom hooks. I've created a simple one updating an internal "step" on creation, cleanup, and allows for external updates. But I'm struggling ...
-2 votes
1 answer
95 views
Can anyone render react-router-dom components with react-testing-library?
After a lot of trial and error I cannot get RTL to render any components from react-router-dom. I am using [email protected], @testing-library/[email protected], @testing-library/[email protected], react-router-...