JSDOM version
jest-preset-angular
provides a way to configure a different version of JSDOM
than the one ships with Jest
via a custom JSDOM
environment. One can follow the below steps to configure a different JSDOM version:
- Install the desired JSDOM version
- npm
- Yarn
- pnpm
npm install -D jsdom@<desired-version>
yarn add --dev jsdom@<desired-version>
pnpm add -D jsdom@<desired-version>
- In Jest config, set the
testEnvironment
like following
- TypeScript CJS
- TypeScript ESM
jest.config.ts
import type { Config } from 'jest';
const jestConfig: Config = {
testEnvironment: 'jest-preset-angular/environments/jsdom',
};
export default jestConfig;
jest.config.mts
import type { Config } from 'jest';
const jestConfig: Config = {
testEnvironment: 'jest-preset-angular/environments/jsdom',
};
export default jestConfig;