Category "jestjs"

Jest TestEnvironment - TypeError: Cannot add property next, object is not extensible

I want to test a node API using Jest. I am testing the routes and websockets. Testing the routes was no problem. I simply started the server using the setupFile

jest is failing to find `bota` and `atob`

Creating a jest test like: test("btoa", () => { expect(btoa("aaa")).toStrictEqual("YWFh"); }); fails with ReferenceError: btoa is not defined however, no

Running jest tests in parallel based on a list of parameters

In my case I have a test file containing a few hundred tests using jest describe('my test-suite', () => { test('test 1', () => { expect(1).toBe(

jest test case for URLSearchParams

search looks like this search: "?productId=1234" and changeId is action const urlParams = new URLSearchParams(window.location.search); const productId = urlP

Jest Call retries were exceeded

I have error in the following below test. My node version is : v12.10.0. is there any alternative of setTimeout? test('demo code', async () => {

Focus event unit test doesn't works in Vuejs / Jest

I want to create a unit test for two events, on focus and on blur. I am using vueJS and jest. handleFocus(event) { if (this.blured === true)

(Apollo client v3) useLazyQuery custom hook testing

I was struggling with a test issue for my custom useLazyQuery hook. My first test is passing but the second one is failing. What am doing wrong for the second t

How can I use jest to spyOn an internal function?

2 questions in 1 here. Why do I get an error message for my jest.spyOn saying that createMappingsDirectory is not a function? Secondly, I think where I’ve

How to mock axios.create([config]) function to return its instance methods instead of overriding them with mock?

I'm trying to mock axios.create() because I'm using its instance across the app and obviously need all of its implementation which is destroyed by the mock, thu

How to unit test typeorm getRepository with Jest?

I am using typescript with typeorm and i have an repository like this: import { EntityRepository, getRepository, createQueryBuilder } from 'typeorm'; @EntityR

Jest: test that an array contains none of these values?

I want to verify that a given array doesn't contain any of a list of values. There is expect.arrayContaining but I don't get how it is supposed to be used for t

How to add module aliases to Jest testing in Next.js?

Currently I am using automatic imports in my Next.js project, configured by jsconfig.json in the root directory: { "typeAcquisition": { "include": ["jest"

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