Category "jestjs"

Jest unable to recognize SVG component

Jest is raising this error on one of my components: Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/fun

What's the best way to test props you pass to child components?

I'm testing a component using Vue test utils and Jest and I'm wondering what's the best way to test you are passing the correct values to a child components in

Cannot read property 'html' of undefined after jest update

For an angular v12 project which uses jest I just updated jest to version 28. Now, however, I get the following error FAIL src/app/components/update-input/upda

How can I test google.maps.Geocoder?

Hi! I'm attempting to write a "simple" test to check for a react class component state change. Specifically, I'm testing if the lat(latitude) and lng(longitu

Svelte - Not able to fetch data from JSON file during jest unit testing

During unit testing, I am getting undefined error, while executing svelte component with json file. Restaurant.svelte : import data from '../Data/restaurants.js

Jest messageParent can only be used inside a worker

Is there a way to get a proper error message? when i do $npm test and I intentionally break my code(cough cough remove a line of code) I get this message src/re

how to test button that call submit form using jest and react testing library

so I am trying to test that the onSubmit function is getting triggered if the button is clicked - the way im doing this is through testing the internals of the

Testing onClose callback which is triggered by clicking outside component

The popup has a click away listener which closes it when a click event occurs outside the component. I need to test that the popup has closed. it.only('clicking

Setting Bearer Token in the header section while testing with Supertest

I'm trying to add the Bearer in the header section in POST request while testing with Supertest. I tried many methods. I'm a beginner in testing. Please suggest

Uncaught TypeError: Cannot read properties of undefined (reading 'isBatchingLegacy')

I am trying to test a react typescript project using jest but it's giving a confusing error: Error image Here is my package.json: "dependencies": { "@testin

How can I share snapshots between Jest tests?

Using TDD I'd like to write some new tests that create data in slightly different ways, and verify that that test data gets sanitized down to the same data as a

Jest test case for React hook component

When I write a react hook component which import '*.png' resource like this: import React, { useState, useEffect } from 'react'; import './topMenu.less'; im

text() method not available in Blob

I am doing some Integration tests with jest & nock to test Axios interceptors chaining. In one of them, I am expecting to receive a Blob instance and accord

Jest: TypeError: replaceAll is not a function

String.prototype.replaceAll() is a useful method and while building and executing everything works fine. However, all Jest-tests fail with the following error:

Can't receive valid test on specific test controller

I'm testing a sign-in controller and therefore I've written the following test: it("return 200 when user signed in successfully", async () => { await req

Jest (unable to set unique href for window.parent.location.href)

I have in my code a check to see if a page is being loaded inside iframe. App.js if (window.location !== window.parent.location) { console.log('App is running

Cannot find memory leak in my Express.js Jest tests

I've now spent some time trying to find memory leaks in my Jest tests, and even though I've successfully tackled some, there's still quite a lot of memory being

How to test NestJs response interceptor

I tried to follow this thread but it I keep getting an error. transform-response.interceptor.ts: import { Injectable, NestInterceptor, ExecutionContext, CallHan

userEvent in React Testing Library Doesn't Cause onClick To Be Called

I'm trying to run a really simple test with react-testing-library where a button is given a mock function, the button is clicked, and the test checks that the f

component props not getting called on test cases

TypeError: Cannot read property 'setState' of null 251 | useStateSpy.mockImplementation((init) => [init, setState]); 252 | const component = shal