diff --git a/config/jest/environment/node.mjs b/config/jest/environment/node.mjs index 8084bc7df4..6626f62b73 100644 --- a/config/jest/environment/node.mjs +++ b/config/jest/environment/node.mjs @@ -1,12 +1,15 @@ -import { TestEnvironment } from 'jest-environment-node' +import SingleContextNodeEnvironment from 'jest-environment-node-single-context' import { globals } from '../globals.mjs' /** - * Default Node.js environment - * Adds shared test globals + * Single context Node.js environment + * Adds real Node.js test globals for Dart Sass + * + * {@link https://github.com/sass/dart-sass#using-sass-with-jest} + * {@link https://github.com/facebook/jest/issues/2549} */ -class NodeEnvironment extends TestEnvironment { +class NodeEnvironment extends SingleContextNodeEnvironment { async setup () { await super.setup() diff --git a/package-lock.json b/package-lock.json index 76adb1e116..480d8a2aba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -68,7 +68,7 @@ "jest-axe": "^7.0.0", "jest-dev-server": "^6.2.0", "jest-environment-jsdom": "^29.3.1", - "jest-environment-node": "^29.3.1", + "jest-environment-node-single-context": "^29.0.0", "jest-environment-puppeteer": "^6.2.0", "jest-serializer-html": "^7.1.0", "lint-staged": "^13.1.0", @@ -13629,6 +13629,18 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/jest-environment-node-single-context": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/jest-environment-node-single-context/-/jest-environment-node-single-context-29.0.0.tgz", + "integrity": "sha512-/XB09Hje38Kl5k9ISUpXNom3M4DQo5ifEsnELPFP5r3yrJDRyNQCEjL/9ScUN6z6UeF4FCNZUsiJIX/tGtTXNw==", + "dev": true, + "dependencies": { + "jest-environment-node": "^29.0.1" + }, + "funding": { + "url": "https://github.com/kayahr/jest-environment-node-single-context?sponsor=1" + } + }, "node_modules/jest-environment-puppeteer": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/jest-environment-puppeteer/-/jest-environment-puppeteer-6.2.0.tgz", @@ -35705,6 +35717,15 @@ "jest-util": "^29.3.1" } }, + "jest-environment-node-single-context": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/jest-environment-node-single-context/-/jest-environment-node-single-context-29.0.0.tgz", + "integrity": "sha512-/XB09Hje38Kl5k9ISUpXNom3M4DQo5ifEsnELPFP5r3yrJDRyNQCEjL/9ScUN6z6UeF4FCNZUsiJIX/tGtTXNw==", + "dev": true, + "requires": { + "jest-environment-node": "^29.0.1" + } + }, "jest-environment-puppeteer": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/jest-environment-puppeteer/-/jest-environment-puppeteer-6.2.0.tgz", diff --git a/package.json b/package.json index 135b075d3c..203c0c3cd4 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "jest-axe": "^7.0.0", "jest-dev-server": "^6.2.0", "jest-environment-jsdom": "^29.3.1", - "jest-environment-node": "^29.3.1", + "jest-environment-node-single-context": "^29.0.0", "jest-environment-puppeteer": "^6.2.0", "jest-serializer-html": "^7.1.0", "lint-staged": "^13.1.0",