Category "jestjs"

Configuring Jest with Rollup and Typescript

I created an app within a monorepo (Lerna) using yarn workspace. The architecture of the app is as follow: my-monorepo ├── node_modules ├

The current testing environment is not configured to support act(...) - @testing-library/react

I'm trying to upgrade my project to React 18, everything works in dev and production mode in the browser. But after upgrading to the latest version of @testing-

Swiper 8 and jest

Swiper 8 and Jest (support ESM) Must use import to load ES Module enter image description here enter image description here How we can solve if I need to keep s

Running a for loop within a Puppeteer test

I'm trying to run a for loop within a Puppeteer test that sends values to a search bar: test('test one', () => { var results = [""] var fuzz = ['ap

Class PublicKey is missing in schema: publicKey

Describe the bug Unable to use the change methods of the contract on jest with near test-environment. I get this error when trying to use the change methods Gre

How to test transition function in Vue 3 test utils?

I have a problem testing transiton functions with jest and vue test utlis. This is my component code: <div class="disclosure"> <button clas

Exceeded timeout of 5000 ms for a test with Jest and MongoDB

I'm trying to implement database population by using a migration function. The code works perfectly, it saves all the data into the database, but the test for t

How to mock only one typescript class from a module, but leave other classes/functions as is, using the jest framework

I have a typescript module with a function that I'm trying to test with jest. The function I'm trying to test uses a typescript class that's defined in the same

I am trying to set a cookie in supertest but it does not work

I am trying to set a cookie session to a post request in supertest but I cannot. This is my test code: const app = express(); app.set("trust proxy", true); app

How to mock a 'request' node module for testing in jest

I am new to writing test cases in jest and i wanted to test 'mark' function and want to mock 'request' node module. let's say this file's name is app.js and tes

Why Jest tests are SOMETIMES failing on CircleCI?

I have Jest tests that are running against the dockerized Neo4j Database, and sometimes they fail on CircleCI. The error message for all 25+ of them is : thrown

Testing function that use useQuery @apollo/client with Jest

I am trying to unit test my function that call useQuery from @apollo/client. Here's what I have done getPixelID.ts import { useQuery } from '@apollo/client'; im

Testing call to other functions within the same component using nuxt.js and jest

I'm trying to write a test that tests the various method calls to other methods within the same file. So far, I've written tests for two different methods, one

how to mock slack web api for jest

i have an app that's using the @slack/web-api package through the named import WebClient. i want to test one of the controllers that uses a model that in turns

Jest: to check if a function is called by a specific instance of class in JavaScript/Typescript

I am testing some express middlewares with jest. it("should throw 400 error if request.body.id is null", () => { const req = { body: { id: null } } as an

What's the point of writing unit tests with mocks, if it cannot catch changes in the source code?

I started writing unit tests recently. When I try to test the service of the Angular component, I usually mock it. Therefore, if someone deletes the line of the

Jest + Supertest - API tests are using random ephemeral ports

I'm using Restify for my API and I'm trying to write tests for my endpoints. At first, I had only a test for ping and it was okay, but now, after I added a new

How to flush promises since Jest 26+

Jest 26 shipped a new implementation of fake timers based on @sinonjs/fake-timers. Previously I used const flushPromises = () => new Promise(setImmediate); a

Testing react component that uses Context - change state of component under test

I want to test the following React component import React, { useContext, useState } from "react"; import { IntlProvider } from "react-intl"; export const Conte

How to conditionally mock error responses with msw

The UI I'm working on is rendered differently based on the response received. I would like to test the UI when a 4xx and 5xx responses are received. My api hand