Skip to content

test(replay): Rewrite custom matcher to be recognized by VSCode #16141

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

Merged
merged 1 commit into from
Apr 28, 2025

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
@@ -4,6 +4,7 @@

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.

@@ -34,15 +35,15 @@ async function waitForFlush() {
}

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.

@@ -163,14 +164,14 @@ describe('Integration | errorSampleRate', () => {
const ADVANCED_TIME = 86400000;
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..

@@ -364,24 +365,6 @@ describe('Integration | errorSampleRate', () => {
},
]),
});

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

@@ -364,24 +365,6 @@ describe('Integration | errorSampleRate', () => {
},
]),
});

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