Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
146 views

I am new in Jest and React Testing Library and want to test my Form created with Formik and Yup. The test should test when the User inputs invalid values, that the Submit Button should be disabled. I ...
Sugirthan's user avatar
1 vote
2 answers
978 views

I've created a minimal repo where this issue is reproduced. If you have time, try it out: https://github.com/Danielvandervelden/jest-error-minimal-repro I have not tried any other editor than VSCode ...
Daniel V.'s user avatar
  • 341
2 votes
0 answers
919 views

I am using a combination of vitest as test runnert, js-dom as dom matcher and @testing-libraries to create react component unit test. After change from jest to vitest, I start getting an error on ...
xzegga's user avatar
  • 3,169
0 votes
1 answer
171 views

I want to test the Hover onto one off my element into my custom lib but there is an issues when testing if the hover correctly apply my chosen style. It seems that my css file is not taken when using ...
Barbu's user avatar
  • 5
0 votes
1 answer
1k views

I am writing tests for React component with @testing-library/react and vitest. Here is my code: It works fine, but for some reason I get these annoying warnings: When I rewrite code to this: then ...
Ihor Zagoruyko's user avatar
3 votes
2 answers
4k views

Context/Setup: I'm trying to use Jest and React-Testing-Library to test the render of a React component <Main/>, but when I run the test, the client that handles fetch throws an error because it'...
dave's user avatar
  • 31
1 vote
2 answers
6k views

I have a component that converts a person's name to two initials with a useMemo. I simply want to test the content to be "SB" when the name is Sjaak de Boer. But the useMemo (or if I simple ...
Bravebox's user avatar
2 votes
1 answer
746 views

I am developing an application with Ionic Angular. While I am testing with @testing-library/angular, the test is not working for ion-button but works for normal button field. What could be the problem?...
Faiz Ahmed's user avatar
3 votes
2 answers
2k views

I am using animate function to animate height of a div. The code looks like this and happens in useLayoutEffect : const animation = ref.current.animate( { height: [oldHeight, newHeight] }...
Vijay P R's user avatar
  • 1,192
-1 votes
1 answer
2k views

I have a component with some parts that are conditionally rendered based on some config on the window object. This all works, I can confirm this manually. I have this sort of test setup, but I have ...
AncientSwordRage's user avatar
5 votes
1 answer
8k views

I'm learning about testing and react. I'm having a little trouble understanding why a test is passing when it should not: From App.js <button style={{backgroundColor: 'gray'}}> ...
rodtrevizan's user avatar
0 votes
1 answer
52 views

How do you test an inner function that is been looped over in jest? Example I have: index.js const innerFunc = (type) => document.querySelector(`input[name="${type}"]`).value; const ...
Mohamed's user avatar
  • 479
2 votes
0 answers
878 views

I am using the latest react-select (https://react-select.com/home) and react-testing-library (https://testing-library.com/docs/react-testing-library/intro/) with jest-dom (https://github.com/testing-...
Patrik Novák's user avatar
2 votes
1 answer
7k views

Having problems setting up ts-jest with jest-dom and react-testing library in a Next JS app, it seems I am unable to get access to any of the @testing-library/jest-dom matchers. Anyone have any ...
Aaron Z's user avatar
  • 93
0 votes
1 answer
4k views

I'm trying to create some tests for a checkbox component but looks like I can't make an assertion for an input[type="checkbox"] when is disabled. In the first two blocks I'm testing if the ...
Vinicius Cainelli's user avatar
1 vote
1 answer
3k views

I'm working on a test code for my React project. What I want to check is 'if the input type is number, it disallow the text insertion'. Below is the test code I wrote. it("disallow a text input&...
bindy's user avatar
  • 23
0 votes
1 answer
3k views

I'm trying to add @testing-library/jest-dom to my project with no luck. It is installed by yarn into my dev dependencies and imported in setupTests.js with: import '@testing-library/jest-dom'; The ...
Hoi Chan's user avatar
0 votes
1 answer
3k views

I am testing a react component which has a simple Material-ui switch that updates a boolean field. The component works without any issues when I run the app locally. In my test, I am mocking the ...
ege's user avatar
  • 930
7 votes
2 answers
3k views

I would like to add React Testing Library to a project that uses mocha and chai for unit tests. I am a bit stumped when it comes to writing assertions, most examples make use of jest and jest-dom. I ...
Frederick Duffield's user avatar
2 votes
0 answers
901 views

I am using react-testing-library with jest-dom. It is working fine but when i try to use toBeInTheDocument it throws the error TypeError: element.getRootNode is not a function. expect(getByText('Not ...
Shubham's user avatar
  • 539
6 votes
4 answers
3k views

I'm testinng a react component using the RTL, and everytime I ran a test, I get, "messageParent" can only be used inside a worker **Here's the code describe('Header', () => { it('...
napster499's user avatar
27 votes
3 answers
76k views

I'm new to unit testing and I'm trying to render a component to learn more about the library. I'm trying to follow this guide. Component <TouchableOpacity style={style} onPress={onPress} ...
theabrar's user avatar
  • 450
0 votes
1 answer
412 views

I have a question about extending Typescript interfaces. Here is my situation: I am using expect in my tests without Jest (I installed it separately and it works). Now I want to use jest-dom to add ...
webNeat's user avatar
  • 2,866
1 vote
2 answers
1k views

I have a unit test in StencilJS in which I am using a jest matcher from jest-dom. When I run the test it throws an error: TypeError: Right-hand side of 'instanceof' is not an object at ...
Ric's user avatar
  • 405
0 votes
1 answer
1k views

I need some help in below test case : appenChild failing in Jest updatePopupContent(data) { const sectionFragment = new DocumentFragment(); //create section return HTML element as per data ...
Bhupendra's user avatar
  • 1,296