From ef0057f6f345cd4ba982d154deac6b161f2f7df8 Mon Sep 17 00:00:00 2001 From: Ahn Date: Tue, 10 Nov 2020 15:44:27 +0100 Subject: [PATCH] refactor(preset): explicitly define `jsdom` for test environment (#621) Jest 27 sets default test environment to `node`. Since we need `jsdom` so we need to explicitly set it in `jest-preset.js`. Jest 27 will still bundle `jest-environment-jsdom` in the main package and Jest 28 will detach them. However, we should just go ahead and set explicitly `jest-environment-jsdom` in our dependencies list More information see https://jestjs.io/blog/2020/05/05/jest-26 --- jest-preset.js | 1 + package.json | 1 + 2 files changed, 2 insertions(+) diff --git a/jest-preset.js b/jest-preset.js index dd57b3771..3515fcbc1 100644 --- a/jest-preset.js +++ b/jest-preset.js @@ -11,6 +11,7 @@ module.exports = { }, }, }, + testEnvironment: 'jsdom', transform: { '^.+\\.(ts|js|html)$': 'ts-jest', }, diff --git a/package.json b/package.json index e8860adf0..5a0a7fbb8 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ }, "dependencies": { "@jest/create-cache-key-function": "^26.5.0", + "jest-environment-jsdom": "^26.6.2", "pretty-format": "26.x", "ts-jest": "^26.2.0" },