Skip to content

Conversation

mydea
Copy link
Member

@mydea mydea commented Apr 28, 2025

I was always annoyed that this was not properly highlighted by VSCode, so I looked into this a bit, and actually refactored it a bit to be more type-safe in the vitest world we now live in :)

I got rid of toHaveSentReplay in favor of simply always using toHaveLastSentReplay (which we already used almost everywhere). I also moved the type definition into a separate file and ensured it actually works, at leas tin my vscode/cursor instance. This also kind of surfaced some type errors that existed in tests, but have not been shown (??) for whatever reason... no idea what is going on there.

@mydea mydea requested review from billyvg and chargome April 28, 2025 09:06
@mydea mydea self-assigned this Apr 28, 2025
@mydea mydea requested a review from a team as a code owner April 28, 2025 09:06

import '../utils/mock-internal-setTimeout';
import { captureException, getClient } from '@sentry/core';
import type { MockInstance } from 'vitest';
Copy link
Member Author

Choose a reason for hiding this comment

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

e.g. this was not imported but still worked, for whatever reason? Now it "correctly" complained about this.

}

describe('Integration | errorSampleRate', () => {
beforeAll(() => {
Copy link
Member Author

Choose a reason for hiding this comment

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

unrelated but also incorrect how it was, oops.

const optionsEvent = createOptionsEvent(replay);

expect(replay.session.started).toBe(BASE_TIMESTAMP);
expect(replay.session?.started).toBe(BASE_TIMESTAMP);
Copy link
Member Author

Choose a reason for hiding this comment

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

this was also incorrectly not flagged?? weird..

]),
});

vi.advanceTimersByTime(DEFAULT_FLUSH_MIN_DELAY);
Copy link
Member Author

Choose a reason for hiding this comment

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

just removed this because it actually irrelevant to this specific test.

Copy link
Member

Choose a reason for hiding this comment

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

Does this behavior get covered in another test?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes!

Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

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

Sweet, thanks!

Copy link
Member

@billyvg billyvg left a comment

Choose a reason for hiding this comment

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

Nice thanks for fixing

]),
});

vi.advanceTimersByTime(DEFAULT_FLUSH_MIN_DELAY);
Copy link
Member

Choose a reason for hiding this comment

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

Does this behavior get covered in another test?

@mydea mydea merged commit f0c9458 into develop Apr 28, 2025
127 checks passed
@mydea mydea deleted the fn/replay-vitest-matcher branch April 28, 2025 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants