From 0d8c51073492c86ead8d299612731cbf526f14a0 Mon Sep 17 00:00:00 2001 From: Kasper Birch Date: Fri, 10 Nov 2023 10:53:19 +0100 Subject: [PATCH] Fix `ReferenceError: process is not defined` Added checks to ensure safe access to `process.env`, addressing environments where it might be undefined. --- src/core/utils/helpers/vitest.ts | 4 ++++ src/core/utils/modal.tsx | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 src/core/utils/helpers/vitest.ts diff --git a/src/core/utils/helpers/vitest.ts b/src/core/utils/helpers/vitest.ts new file mode 100644 index 0000000000..403bd225c8 --- /dev/null +++ b/src/core/utils/helpers/vitest.ts @@ -0,0 +1,4 @@ +export const isVitestEnvironment = + typeof process !== "undefined" && process.env && process.env.VITEST; + +export default {}; diff --git a/src/core/utils/modal.tsx b/src/core/utils/modal.tsx index 41a0659f74..6f3da16c62 100644 --- a/src/core/utils/modal.tsx +++ b/src/core/utils/modal.tsx @@ -9,6 +9,7 @@ import { currentLocationWithParametersUrl, redirectToLoginAndBack } from "./helpers/url"; +import { isVitestEnvironment } from "./helpers/vitest"; type ModalId = string; @@ -69,7 +70,7 @@ function Modal({