Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(core): Improve offline transport test performance #13460

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We previously skipped this test because it was flaky. I'm gonna un-skip it for now. Maybe using fake timers and or vitest helps. If we notice it being flaky, we should fix the test this time

'Follows the Retry-After header',
async () => {
const { getCalls, store } = createTestStore(ERROR_ENVELOPE);
Expand Down
Loading