Skip to content

Commit 0b72bbc

Browse files
authored
fix testoptions (#303)
1 parent dc546e2 commit 0b72bbc

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/core/src/extensions/UniqueID/UniqueID.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ const UniqueID = Extension.create({
5252
types: [],
5353
generateID: () => {
5454
// Use mock ID if tests are running.
55-
if ((window as any).__TEST_OPTIONS) {
56-
if ((window as any).__TEST_OPTIONS.mockID === undefined) {
57-
(window as any).__TEST_OPTIONS.mockID = 0;
55+
if (typeof window !== "undefined" && (window as any).__TEST_OPTIONS) {
56+
const testOptions = (window as any).__TEST_OPTIONS;
57+
if (testOptions.mockID === undefined) {
58+
testOptions.mockID = 0;
5859
} else {
59-
(window as any).__TEST_OPTIONS.mockID++;
60+
testOptions.mockID++;
6061
}
6162

62-
return (window as any).__TEST_OPTIONS.mockID.toString() as string;
63+
return testOptions.mockID.toString() as string;
6364
}
6465

6566
return v4();

0 commit comments

Comments
 (0)