2023-06-21 09:28:00 +00:00
|
|
|
// @ts-strict-ignore
|
2022-12-07 10:20:09 +00:00
|
|
|
import "@testing-library/jest-dom";
|
|
|
|
|
2022-12-02 11:58:43 +00:00
|
|
|
import { configure } from "@testing-library/react";
|
|
|
|
|
2022-10-27 15:26:09 +00:00
|
|
|
document.getElementById = () => document.createElement("div");
|
2022-11-16 15:01:34 +00:00
|
|
|
|
2023-01-24 13:59:14 +00:00
|
|
|
// workaround for `jsdom`
|
|
|
|
// https://github.com/jsdom/jsdom/issues/3002
|
|
|
|
document.createRange = () => {
|
|
|
|
const range = new Range();
|
|
|
|
|
|
|
|
range.getBoundingClientRect = jest.fn();
|
|
|
|
|
|
|
|
range.getClientRects = () => ({
|
|
|
|
item: () => null,
|
|
|
|
length: 0,
|
|
|
|
[Symbol.iterator]: jest.fn(),
|
|
|
|
});
|
|
|
|
|
|
|
|
return range;
|
|
|
|
};
|
|
|
|
|
2022-11-16 15:01:34 +00:00
|
|
|
window.__SALEOR_CONFIG__ = {
|
|
|
|
API_URL: "http://localhost:8000/graphql/",
|
|
|
|
APP_MOUNT_URI: "/",
|
2023-01-10 10:04:30 +00:00
|
|
|
APPS_MARKETPLACE_API_URI: "http://localhost:3000",
|
|
|
|
APPS_TUNNEL_URL_KEYWORDS: ".ngrok.io;.saleor.live",
|
2023-03-03 08:34:18 +00:00
|
|
|
IS_CLOUD_INSTANCE: "true",
|
2022-11-16 15:01:34 +00:00
|
|
|
};
|
2022-12-02 11:58:43 +00:00
|
|
|
|
2022-12-07 10:20:09 +00:00
|
|
|
process.env.TZ = "UTC";
|
|
|
|
|
2022-12-02 11:58:43 +00:00
|
|
|
configure({ testIdAttribute: "data-test-id" });
|
2023-05-25 13:35:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* https://github.com/inrupt/solid-client-authn-js/issues/1676
|
|
|
|
*
|
|
|
|
* Fixes (hacks) "TextEncoder is not defined" error which is likely bug in jsdom
|
|
|
|
*/
|
|
|
|
import { TextDecoder, TextEncoder } from "util";
|
|
|
|
global.TextEncoder = TextEncoder;
|
|
|
|
global.TextDecoder = TextDecoder;
|