test: fix 'window is not defined'

This commit is contained in:
Zeke Zhang 2023-12-29 11:26:36 +08:00
parent 496f43abf1
commit aefabffd77

View File

@ -34,6 +34,10 @@ Object.defineProperty(window, 'matchMedia', {
const { getComputedStyle } = window;
window.getComputedStyle = (elt) => getComputedStyle(elt);
// 解决 https://github.com/nocobase/nocobase/actions/runs/7353181446/job/20018831007?pr=3282
// 该错误是发生在测试环境之后的,应该是存在异步代码没有 await 导致的,但是不知道是哪里的问题,所以先这样处理
global.window = window;
/**
* TypeError: range.getBoundingClientRect is not a function
* https://github.com/jsdom/jsdom/issues/3002