-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
@@ -4,6 +4,7 @@ | |||
|
|||
import '../utils/mock-internal-setTimeout'; | |||
import { captureException, getClient } from '@sentry/core'; | |||
import type { MockInstance } from 'vitest'; |
There was a problem hiding this comment.
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(() => { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet, thanks!
There was a problem hiding this 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); |
There was a problem hiding this comment.
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?
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 usingtoHaveLastSentReplay
(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.