Skip to content

Commit

Permalink
test(core): Improve offline transport test performance
Browse files Browse the repository at this point in the history
switch to fake timers
  • Loading branch information
Lms24 committed Aug 26, 2024
1 parent 0c0fe61 commit 4c2647d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/core/test/lib/transports/offline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -162,7 +162,9 @@ function waitUntil(fn: () => boolean, timeout: number): Promise<void> {
}

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;
Expand All @@ -174,6 +176,9 @@ describe('makeOfflineTransport', () => {
return true;
},
});

vi.runAllTimersAsync();

const result = await transport.send(ERROR_ENVELOPE);

expect(result).toEqual({ statusCode: 200 });
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4c2647d

Please sign in to comment.