test: fix flaky in customElements (#2109)

This commit is contained in:
Himself65
2023-04-24 13:18:37 -05:00
committed by GitHub
parent c27c241482
commit ef8dea8cb2
3 changed files with 13 additions and 121 deletions
+12
View File
@@ -0,0 +1,12 @@
import { vi } from 'vitest';
if (typeof window !== 'undefined') {
// Refs: https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/custom-elements/CustomElementRegistry-impl.js
const customElements = {
define: vi.fn(),
get: vi.fn(),
whenDefined: vi.fn(),
upgrade: vi.fn(),
};
vi.stubGlobal('customElements', customElements);
}