Skip to content

Commit

Permalink
Fix ReferenceError: process is not defined
Browse files Browse the repository at this point in the history
Added checks to ensure safe access to `process.env`, addressing environments where it might be undefined.
  • Loading branch information
kasperbirch1 committed Nov 13, 2023
1 parent 691e777 commit 0d8c510
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/utils/helpers/vitest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const isVitestEnvironment =
typeof process !== "undefined" && process.env && process.env.VITEST;

export default {};
3 changes: 2 additions & 1 deletion src/core/utils/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
currentLocationWithParametersUrl,
redirectToLoginAndBack
} from "./helpers/url";
import { isVitestEnvironment } from "./helpers/vitest";

type ModalId = string;

Expand Down Expand Up @@ -69,7 +70,7 @@ function Modal({
<FocusTrap
focusTrapOptions={{
// Set fallbackFocus when running vitest to avoid focus trap errors.
fallbackFocus: process.env.VITEST ? "body" : undefined
fallbackFocus: isVitestEnvironment ? "body" : undefined
}}
>
<div>
Expand Down

0 comments on commit 0d8c510

Please sign in to comment.