22,935 questions
Tooling
0 votes
2 replies
47 views
How to write tests which analyze HTTP requests made on NextJS server side?
I work on a NextJS project with Pages Router. We are using Jest for unit tests and Playwright for E2E. The application we are making is a funnel with several steps. Each step is a form with several ...
1 vote
1 answer
54 views
Jest + Testcontainers MongoDB: Intermittent ECONNREFUSED errors running integration tests
Problem Starting November 10th, my Jest integration tests began failing randomly with MongoDB connection errors. The tests use @testcontainers/mongodb v11.5.1 and mongodb v8.0.12. Error: ...
-1 votes
0 answers
44 views
Unit test for React/Chakra [closed]
This is my parent component. import { useState } from 'react'; import VButton from 'ui-components/src/v2/VButton.jsx'; import { Provider } from 'ui-components/src/v2/providers/chakra.jsx'; import { ...
0 votes
1 answer
50 views
When upgrading to React 19 and NextJS 15, jest snapshots that had header changes via `next/head` break
In our tests, we had several snapshots that included content wrapped in next/head. We had previously followed the below pattern for the mock, which allowed us to see all the header tags like meta, ...
-1 votes
0 answers
57 views
Argument of type 'PoolConnection' is not assignable to parameter of type 'never'
I want to mock transaction as PoolConnection jest.mock('../../src/config/db.js', () => ({ __esModule: true, default: { execute: jest.fn(), query: jest.fn(), ...
1 vote
0 answers
88 views
Problem with toHaveBeenCalledWith called from window object
This is my unit test: import '@testing-library/jest-dom/extend-expect'; import { render, cleanup, fireEvent, waitFor, waitForElementToBeRemoved, screen, } from '@testing-library/svelte'; ...
1 vote
1 answer
82 views
Zustand persist doesn't execute in testing
I am doing unit testing for my project. This is the code I want to test: import { create } from "zustand"; import { persist } from "zustand/middleware"; interface LanguageState { ...
0 votes
1 answer
39 views
Why is jest `globalSetup` not run for certain project-related invocations? [closed]
I have a TypeScript monorepo that uses jest, and has a globalSetup script configured at the root config (it starts a local database process that many of the tests use). Example Directory structure ...
0 votes
1 answer
73 views
Element type is invalid on render method of "App" using Jest
I am attempting to run a simple Jest test to render the App element. This is our App.test.tsx: test('render application', () => { render(<App />); } This is the error that is being ...
0 votes
0 answers
40 views
Jest/Puppeteer test for a Chrome Extension fails with timeout on Firestore getDoc, but manual tests and Cloud Function succeed
I am building a Manifest V3 Chrome Extension using Firebase and testing it with Jest and Puppeteer. My manual testing works perfectly, but one specific automated test consistently fails with a 30-...
0 votes
0 answers
38 views
jest object in setupFilesAfterEnv differs from jest in test files
I’m trying to add a custom method onto the Jest API inside a setup file (config.ts) configured via setupFilesAfterEnv. However, the jest object I mutate in the setup file is NOT the same reference as ...
0 votes
0 answers
428 views
Mock jsdom Location using @jest/environment-jsdom-abstract
Jest 30 uses JSDOM 26, which breaks my tests. I want to test if location.search was modified. Since JSDOM 21, it is not possible to mock location.search as easily as it used to be: // does not work ...
0 votes
0 answers
85 views
Jest hangs when publishing to @google-cloud/pubsub in integration test
I have an integration test that publishes a domain event to Google Cloud Pub/Sub (using the Pub/Sub emulator). Eventduspatcher.integration.test.ts passes but Jest prints: Jest did not exit one second ...
0 votes
0 answers
197 views
Failed to parse the TypeScript config file with Jest 30.x and Node 22.18+
I'm running into some inconsistent behavior with Jest 30.x, specifically when parsing a jest.config.ts file that imports another TypeScript module, on Node.js 22.18+. My code uses ESM syntax for the ...
1 vote
0 answers
46 views
Is Jest cache shared with other projects on a CI server?
My question is related to Enabling Jest cache in CI servers but a bit more specific. We use Jest with cache enabled on a CI server running tests on multiple projects. By default, Jest uses /tmp/...