Skip to content

Commit 4c2647d

Browse files
committed
test(core): Improve offline transport test performance
switch to fake timers
1 parent 0c0fe61 commit 4c2647d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/core/test/lib/transports/offline.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
parseEnvelope,
1818
} from '@sentry/utils';
1919

20-
import { describe, expect, it } from 'vitest';
20+
import { describe, expect, it, vi } from 'vitest';
2121
import { createTransport } from '../../../src';
2222
import type { CreateOfflineStore, OfflineTransportOptions } from '../../../src/transports/offline';
2323
import { START_DELAY, makeOfflineTransport } from '../../../src/transports/offline';
@@ -162,7 +162,9 @@ function waitUntil(fn: () => boolean, timeout: number): Promise<void> {
162162
}
163163

164164
describe('makeOfflineTransport', () => {
165-
it('Sends envelope and checks the store for further envelopes', async () => {
165+
vi.useFakeTimers();
166+
167+
it('sends envelope and checks the store for further envelopes', async () => {
166168
const { getCalls, store } = createTestStore();
167169
const { getSendCount, baseTransport } = createTestTransport({ statusCode: 200 });
168170
let queuedCount = 0;
@@ -174,6 +176,9 @@ describe('makeOfflineTransport', () => {
174176
return true;
175177
},
176178
});
179+
180+
vi.runAllTimersAsync();
181+
177182
const result = await transport.send(ERROR_ENVELOPE);
178183

179184
expect(result).toEqual({ statusCode: 200 });
@@ -411,7 +416,7 @@ describe('makeOfflineTransport', () => {
411416
START_DELAY + 2_000,
412417
);
413418

414-
it.skip(
419+
it(
415420
'Follows the Retry-After header',
416421
async () => {
417422
const { getCalls, store } = createTestStore(ERROR_ENVELOPE);

0 commit comments

Comments
 (0)