Skip to content

Commit

Permalink
Remove values mock from test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nicknovitski committed Sep 10, 2024
1 parent 41773e1 commit ca33e3d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/ExpoClientValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
11 changes: 1 addition & 10 deletions src/__tests__/ExpoClient-test.ts
Original file line number Diff line number Diff line change
@@ -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();
});
Expand Down

0 comments on commit ca33e3d

Please sign in to comment.