mirror of
https://github.com/bitwarden/clients.git
synced 2026-11-16 07:03:29 +00:00
* [deps] Platform: Update jest-environment-jsdom to v30
* Fix jsdom 26 test compatibility for jest-environment-jsdom v30
jsdom 26 defines its [LegacyUnforgeable] globals (window, document,
location, top) as non-configurable, so tests that replace them with
Object.defineProperty or jest.spyOn now throw "Cannot redefine property".
Add a jsdom test environment composed via @jest/environment-jsdom-abstract
that relaxes only those four globals to configurable, and use it for all
Angular-based projects. Also drop two assertions that only observed jsdom's
internal getComputedStyle-to-element.style delegation, and refresh snapshots
for jsdom 26's quoted url("...") CSS serialization.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
/* eslint-env node */
|
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
const path = require("path");
|
|
|
|
const { createCjsPreset } = require("jest-preset-angular/presets");
|
|
|
|
const presetConfig = createCjsPreset({
|
|
tsconfig: "<rootDir>/tsconfig.spec.json",
|
|
astTransformers: {
|
|
before: ["<rootDir>/../../libs/shared/es2020-transformer.ts"],
|
|
},
|
|
diagnostics: {
|
|
ignoreCodes: ["TS151001"],
|
|
},
|
|
});
|
|
|
|
/** @type {import('jest').Config} */
|
|
module.exports = {
|
|
...presetConfig,
|
|
testMatch: ["**/+(*.)+(spec).+(ts)"],
|
|
|
|
// jsdom marks window, document, location, and top as non-configurable; this
|
|
// environment relaxes them so tests can replace them with Object.defineProperty.
|
|
testEnvironment: path.resolve(__dirname, "jsdom-configurable.environment.ts"),
|
|
|
|
// oauth4webapi is ESM-only; allow jest-preset-angular's transformer to compile it.
|
|
transformIgnorePatterns: [
|
|
"node_modules/(?!(.*\\.mjs$|@angular/common/locales/.*\\.js$|oauth4webapi/.*))",
|
|
],
|
|
|
|
setupFiles: [path.resolve(__dirname, "polyfill-node-globals.ts")],
|
|
|
|
testPathIgnorePatterns: [
|
|
"/node_modules/", // default value
|
|
".*.type.spec.ts", // ignore type tests (which are checked at compile time and not run by jest)
|
|
],
|
|
|
|
// Improves on-demand performance, for watches prefer 25%, overridable by setting --maxWorkers
|
|
maxWorkers: "50%",
|
|
};
|