Skip to content

Commit

Permalink
fix: Reference global object using globalThis (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardscarrott committed May 8, 2024
1 parent a4bd606 commit 0a66e49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/reporter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ describe('verbose reporter', () => {
});

it('falls back to Date when performance is not globally available', async () => {
const backup = global.performance;
delete (global as any).performance;
const backup = globalThis.performance;
delete (globalThis as any).performance;
const cache = new Map<string, CacheEntry>();
const logger = createLogger();

Expand All @@ -165,7 +165,7 @@ describe('verbose reporter', () => {
verboseReporter({ logger }),
);

(global as any).performance = backup;
(globalThis as any).performance = backup;
expect(Date.now).toBeCalledTimes(3);
});

Expand Down
2 changes: 1 addition & 1 deletion src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ interface ReporterOpts {
export function verboseReporter<Value>({
formatDuration = defaultFormatDuration,
logger = console,
performance = global.performance || Date,
performance = globalThis.performance || Date,
}: ReporterOpts = {}): CreateReporter<Value> {
return ({ key, fallbackToCache, forceFresh, metadata, cache }) => {
const cacheName =
Expand Down

0 comments on commit 0a66e49

Please sign in to comment.