Questions tagged [testing-library]

Questions about testing JavaScript code with the Testing Library utilities

282 questions
0
votes
0 answers

How to dry up queries in testing-libray/react library

I have a following simple test for dummy Counter component: describe("Counter", () => { it("initially displays 0", () => { render(); expect(screen.getByText("Counter value is 0")).toBeInTheDocument(); }); it("displays the…
luacassus
  • 6,540
  • 2
  • 40
  • 58
0
votes
1 answer

React - Test separate parent component (without redux)

I wanna test parent component, but I want to do this without redux. I have problem because I've got error: Invariant Violation: Could not find "store" in either the context or props of "Connect(MarkerList)". Either wrap the root component in a , or…
Lukas
  • 19
  • 4
0
votes
1 answer

Cant find a button in react testing library with getByDisplayValueText

I have a simple component that has 3 buttons. i want to find the buttons and simulate click by using react testing library. problem is that I cant find the first button in my test by below code. considering I have a button with value="All" and…
0
votes
1 answer

How to test typescript application using jest with testing libraray?

I am trying to test the typescript app ( without any js frameworks ). But do not have any idea about it. is it possible to test with testing library at all? any one share me a guide or help me to test this simple ts file? here is my ts file with…
user2024080
  • 1
  • 14
  • 56
  • 96
-1
votes
1 answer

Is there any way to get dl, dt or dd tags by role in testing library?

I would like to get dd tag by role using the testing library
ID
123456
I tried: screen.getByRole('term', { name: 'ID' }) and screen.getByRole('definition', { name: 'ID' }) But it didn't…
Konrad
  • 21,590
  • 4
  • 28
  • 64
-1
votes
1 answer

How to read a button which contains text with asterisk in javascript

Can anyone please help me with the below statement I am trying to get the element by text which contains asterisk const readButton = test.getByText('Read the rules *');
-1
votes
1 answer

Testing library: You called act(async () => ...) without await

I'm writing some react unit tests and I keep getting this warning in my console but I'm not sure if I'm actually doing anything wrong. it('correctly returns postcodes found', async () => { const { input, user, onPostcodeLookup } = setup(); …
lpetrucci
  • 1,285
  • 4
  • 22
  • 40
-1
votes
1 answer

when using testing-library jest runs too many tests...not the ones I want

For some reason I can't seem to split out "cypress, puppeteer and jest unit tests" into separate commands: package.json: "test:jest": "jest ./src", "e2e:pptr": "npm run dev & jest ./tests", "e2e:cypress": "npm run dev &…
chovy
  • 72,281
  • 52
  • 227
  • 295
-1
votes
2 answers

What does this part of the Redux document mean?

I'm using the Redux-tool kit to set it up. We are now using @testing-library/react to set up testing-related settings. I got a question while looking at the official document. // test-utils.js import React from 'react' import { render as rtlRender…
-1
votes
1 answer

How to test the private methods/declarations using "testing-library"

Is there any way to test the private method or declaration using "testing-library" framework in angular? here is my code: priave name = "somename" private setLang(url: string, fetch: boolean) { switch (url) { case '/SSB/mngt': …
3gwebtrain
  • 14,640
  • 25
  • 121
  • 247
-2
votes
1 answer

Jest tests fails to find all elements with role="alert" using findAllByRole method

I have a toast component that spawns success and error toast on clicking on the success and error buttons respectively. Demo - Link I have written a test using jest and @testing-library/dom - import '@testing-library/jest-dom'; import { screen }…
Stack
  • 429
  • 1
  • 4
  • 12
1 2 3
18
19