Questions tagged [jest-dom]

56 questions
2
votes
0 answers

Jest Unit test is failing for @microsoft/mgt-components even after adding the node_module to transformIgnorePatterns

I am using Microsoft authentication within my App to enable users to login. The flow itself is working seamlessly but the unit test is failing. I have added @microsoft to the transformIgnorePatterns property but seems like it is still not being…
hushie
  • 417
  • 10
  • 23
2
votes
1 answer

Property 'toBeInTheDocument' does not exist on type 'Matchers'

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 insights about this sort of setup with typescript and…
2
votes
0 answers

TypeError: element.getRootNode is not a function while testing

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 in dom')).not.toBeInTheDocument(); // It…
Shubham
  • 497
  • 10
  • 23
2
votes
1 answer

Jest Unit test cant determine Vuetify components visibility

I have a Vue2 project with Vuetify, and i am using Jest for unit testing my code. I am starting out testing some sample code and i simple cannot get Jest to determine if a Vuetify v-alert component is visible or not. I have tried the built in Jest…
user616
  • 783
  • 4
  • 18
  • 44
1
vote
0 answers

Echarts problem with vitest and react-testing-libraries

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 every component that has Echarts included. I open…
xzegga
  • 3,051
  • 3
  • 25
  • 45
1
vote
1 answer

React + Jest: test hangs forever whenever I try to access DOM properties (i.e.: toHaveStyle)

For the past few months my tests have been working perfectly. My package versions are fixed, not ranges, and we have not updated any dependency. However, since three days ago, the tests won't run at all. Jest just hangs in the [RUNS]…
Unapedra
  • 2,043
  • 4
  • 25
  • 42
1
vote
2 answers

Jest-dom TypeError: $toString is not a function , Typescript, React, Next.js

I've been trying to configure jest and @testing-library/jest-dom to work with my typescript/react/next.js website. Every-time I run the test I run into this issue and Im not sure exactly what is causing it. I've been stuck on it for 3 days now and…
1
vote
1 answer

Reasons to use getBy* in conjunction with toBeInTheDocument

There are plenty of examples of getBy* or findBy* queries are used in conjunction with expect().toBeInTheDocument(). At the same time the Testing Library docs say that both of those type of queries throw errors when 0 elements match. So there is a…
maximalism
  • 71
  • 1
  • 4
1
vote
1 answer

Testing the return value from an useMemo with React/Jest

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 convert it to a return function) is slow so the test…
Bravebox
  • 33
  • 6
1
vote
0 answers

Vue Testing Library - Error in beforeCreate hook: "TypeError: Cannot read properties of null (reading 'init')"

I am writing my very first tests using @testing-library/vue. I am using Vue 2.7 and the version for testing-library/vue is ^5.6.1. Here is the component: