From ca33e3d8082d466884ae5a9ce564d5a6e80eaac5 Mon Sep 17 00:00:00 2001 From: Nick Novitski Date: Tue, 10 Sep 2024 13:09:50 -0700 Subject: [PATCH] Remove values mock from test It's easy for this mock to fall out of sync with the actual module, and solutions which would prevent this would be verbose and cluttered. The only thing it achieves is keeping the tests fast with a lower retry timeout, and that can also be achieved with a switch on NODE_ENV. --- src/ExpoClientValues.ts | 2 +- src/__tests__/ExpoClient-test.ts | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/ExpoClientValues.ts b/src/ExpoClientValues.ts index 3030ff0..9213977 100644 --- a/src/ExpoClientValues.ts +++ b/src/ExpoClientValues.ts @@ -30,4 +30,4 @@ export const defaultConcurrentRequestLimit = 6; /** * Minimum timeout in ms for request retries. */ -export const requestRetryMinTimeout = 1000; +export const requestRetryMinTimeout = process.env['NODE_ENV'] === 'test' ? 1 : 1000; diff --git a/src/__tests__/ExpoClient-test.ts b/src/__tests__/ExpoClient-test.ts index 0ded5a2..9836481 100644 --- a/src/__tests__/ExpoClient-test.ts +++ b/src/__tests__/ExpoClient-test.ts @@ -1,19 +1,10 @@ -import { jest, afterEach, beforeEach, describe, test, expect } from '@jest/globals'; +import { afterEach, beforeEach, describe, test, expect } from '@jest/globals'; import fetch from 'node-fetch'; import assert from 'node:assert'; import ExpoClient, { ExpoPushMessage } from '../ExpoClient'; import { getReceiptsApiUrl, sendApiUrl } from '../ExpoClientValues'; -jest.mock('../ExpoClientValues', () => ({ - requestRetryMinTimeout: 1, - pushNotificationChunkLimit: 100, - sendApiUrl: 'http://localhost:3000/--/api/v2/push/send', - getReceiptsApiUrl: 'http://localhost:3000/--/api/v2/push/getReceipts', - pushNotificationReceiptChunkLimit: 300, - defaultConcurrentRequestLimit: 6, -})); - afterEach(() => { (fetch as any).reset(); });