From 4c2647dd35d49b7d140b89d538fa647a3a0dff01 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 20 Aug 2024 10:24:24 +0200 Subject: [PATCH] test(core): Improve offline transport test performance switch to fake timers --- packages/core/test/lib/transports/offline.test.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/core/test/lib/transports/offline.test.ts b/packages/core/test/lib/transports/offline.test.ts index 736002a95d7e..28969eed5474 100644 --- a/packages/core/test/lib/transports/offline.test.ts +++ b/packages/core/test/lib/transports/offline.test.ts @@ -17,7 +17,7 @@ import { parseEnvelope, } from '@sentry/utils'; -import { describe, expect, it } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; import { createTransport } from '../../../src'; import type { CreateOfflineStore, OfflineTransportOptions } from '../../../src/transports/offline'; import { START_DELAY, makeOfflineTransport } from '../../../src/transports/offline'; @@ -162,7 +162,9 @@ function waitUntil(fn: () => boolean, timeout: number): Promise { } describe('makeOfflineTransport', () => { - it('Sends envelope and checks the store for further envelopes', async () => { + vi.useFakeTimers(); + + it('sends envelope and checks the store for further envelopes', async () => { const { getCalls, store } = createTestStore(); const { getSendCount, baseTransport } = createTestTransport({ statusCode: 200 }); let queuedCount = 0; @@ -174,6 +176,9 @@ describe('makeOfflineTransport', () => { return true; }, }); + + vi.runAllTimersAsync(); + const result = await transport.send(ERROR_ENVELOPE); expect(result).toEqual({ statusCode: 200 }); @@ -411,7 +416,7 @@ describe('makeOfflineTransport', () => { START_DELAY + 2_000, ); - it.skip( + it( 'Follows the Retry-After header', async () => { const { getCalls, store } = createTestStore(ERROR_ENVELOPE);