npm
npmjs.com › package › jest-environment-node
jest-environment-node - npm
1 week ago - Latest version: 30.4.1, last published: 7 days ago. Start using jest-environment-node in your project by running `npm i jest-environment-node`. There are 1184 other projects in the npm registry using jest-environment-node.
» npm install jest-environment-node
Published May 08, 2026
Version 30.4.1
Videos
Stack Overflow
stackoverflow.com › questions › 68627205 › use-jest-inside-jest-test-environment
Use jest inside Jest Test Environment - javascript
I have created a Jest test environment in which I mock a specific module: const NodeEnvironment = require('jest-environment-node'); const { lumigo } = require('../../src/services/lumigo'); class
npm
npmjs.com › package › @jest › environment
@jest/environment - npm
September 1, 2025 - Latest version: 30.2.0, last published: 2 months ago. Start using @jest/environment in your project by running `npm i @jest/environment`. There are 72 other projects in the npm registry using @jest/environment.
» npm install @jest/environment
Jest
jestjs.io › configuring jest
Configuring Jest · Jest
1 week ago - Use the <rootDir> string token to include the path to your project's root directory to prevent it from accidentally ignoring all of your files in different environments that may have different root directories. ... An alternative API to setting the NODE_PATH env variable, modulePaths is an array of absolute paths to additional locations to search when resolving modules. Use the <rootDir> string token to include the path to your project's root directory. ... Activates native OS notifications for test results. To display the notifications Jest needs node-notifier package, which must be installed additionally:
Jest
jestjs.io › test environment
Test Environment · Jest
1 week ago - To have more fine-grained control, you can use docblock pragmas to specify environment for specific files. Docblock pragmas are comments that start with @jest-environment and are followed by the environment name: ... Jest allows you to extend the built-in environments, such as NodeEnvironment or JSDOMEnvironment, to create your own custom environment.
Medium
medium.com › @yiqun.rong2 › jest-test-lifecycle-and-test-environment-06cfbf90f612
Jest test lifecycle and test environment | by Rong | Medium
December 3, 2023 - It does not mock a DOM and is best suited for testing code that runs in a Node.js context, like server-side scripts, APIs, or command-line tools. We can also create custom test environments in Jest. This is useful if you have specific requirements that are not met by the built-in environments.
GitHub
github.com › jestjs › jest › issues › 12573
[Feature]: Allow `@jest-environment` pragma to be below other comments · Issue #12573 · jestjs/jest
March 12, 2022 - 🚀 Feature Proposal Allow the /** * @jest-environment jsdom */ To not be strictly the first comment node. Motivation Docusaurus has a very strict eslint header config that only allows: /** * Copyrig...
Author Josh-Cena
Stack Overflow
stackoverflow.com › questions › 73865763 › use-jest-environment-jsdom-and-jest-environment-node-both-in-the-same-project
Use @jest-environment jsdom and @jest-environment node both in the same project [Jest-ReactJS]
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ module.exports = { preset: 'ts-jest', testEnvironment: 'node' }; I have tried below approach, but it didn't work in my experience. /** * @jest-environment jsdom */ test('use jsdom in this test file', () => { const element = document.createElement('div'); expect(element).not.toBeNull(); }); /** * @jest-environment node */ test('do not use jsdom in this test file', () => { console.log(window); // this will fail as node doesn't have a window object });
GitHub
github.com › capricorn86 › happy-dom › wiki › Jest-Environment
Jest Environment · capricorn86/happy-dom Wiki
September 28, 2025 - npm install --save-dev @jest/environment @jest/fake-timers @jest/types @jest/mock @jest/util @happy-dom/jest-environment · Jest uses node as test environment by default.
Author capricorn86
GitHub
github.com › jestjs › jest › issues › 6634
@jest-environment node not working · Issue #6634 · jestjs/jest
July 5, 2018 - /** * @jest-environment node */ import { URL } from './config'; describe('Config on NodeJS environment', () => { test('it should be a relative url', () => { expect(URL).toBeFalsy(); }); });
Author StefanoSega
Top answer 1 of 2
5
In my case, the solution was:
- Install this package: jest-environment-jsdom
- Add
testEnvironment: 'jest-environment-jsdom'into myjest.config.js; - Run
yarn test(my script:"test": "jest --verbose")
You can see better bellow or the file here in repository ShareBookBR/sharebook-frontend-next
module.exports = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
testPathIgnorePatterns: ['<rootDir>/.next/', '<rootDir>/node_modules/'],
moduleNameMapper: {
//To include new paths, include also into tsconfig.paths.json
'\\.(scss|sass|css)$': 'identity-obj-proxy',
// '^@/sharebook-components/(.*)$': '<rootDir>/components/$1', //to all paths, ex: @sharebook-components/somegfolder
'^@sharebook-themes': '<rootDir>/src/themes',
'^@sharebook-layouts': '<rootDir>/src/layouts',
'^@sharebook-components': '<rootDir>/src/components',
'^@sharebook-hooks': '<rootDir>/src/hooks',
'^@sharebook-configs': '<rootDir>/src/configs',
'^@sharebook-axios': '<rootDir>/src/axios',
'^@sharebook-utils': '<rootDir>/src/utils'
},
testEnvironment: 'jest-environment-jsdom'
};
2 of 2
1
You can add the testing environment in jest config file just like
module.exports = {
verbose: true,
testEnvironment: 'jsdom',
setupFiles: ['./src/__mocks__/client.js'],
setupFilesAfterEnv: ['./jest.setup.js', '@testing-library/jest-dom/extend-expect'],
moduleDirectories: ['node_modules', 'src'],
moduleNameMapper: {
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
},
testEnvironment: 'jsdom'
}
jsDocs.io
jsdocs.io › package › jest-environment-node
jest-environment-node@30.2.0 - jsDocs.io
@jest/environment · @jest/fake-timers · @jest/types · @types/node · jest-mock · jest-util · jest-validate · @jest/test-utils · clsx · No peer dependencies. To add a badge like this oneto your package's README, use the codes available below. You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/jest-environment-node.
GitHub
github.com › jestjs › jest › issues › 3280
@jest-environment jsdom not working · Issue #3280 · jestjs/jest
April 11, 2017 - I'd like to report a bug. What is the current behavior? When setting the jest environment to node in the package.json and using the @jest-environment jsdom docblock in a UI test, jsdom is not available. If the current behavior is a bug, ...
Published Apr 11, 2017
npm
npmjs.com › package › jest-environment-node-single-context
jest-environment-node-single-context - npm
January 29, 2024 - One of Jest's key features is context isolation so tests can't have side-effects on other tests by manipulating the global context. In theory that's a good idea but in practice the current implementation messes around with global types in a way which breaks pretty much all instanceof checks in tests against standard types like Uint8Array for example. This small project provides a single-context Node.js environment which effectively sacrifices the context isolation feature by using a single context for all tests so instanceof checks works again as expected.
» npm install jest-environment-node-single-context
Published Jan 29, 2024
Version 29.4.0