-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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(replay): Normalize time offset in DOM snapshots #7219
Conversation
*/ | ||
export function normalize(obj: unknown): string { | ||
const rawString = JSON.stringify(obj, null, 2); | ||
const normalizedString = rawString.replace(/"file:\/\/.+(\/.*\.html)"/g, '"$1"'); | ||
const normalizedString = rawString | ||
.replace(/"file:\/\/.+(\/.*\.html)"/, '"$1"') |
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.
m: should both of these regexes have a /gm
(or at least /g
, not 100% sure tbh) suffix? I
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.
Done, plus another regex fix (I didn't take negative offsets into account)
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.
Do we need to also update snapshots?
const normalizedString = rawString.replace(/"file:\/\/.+(\/.*\.html)"/g, '"$1"'); | ||
const normalizedString = rawString | ||
.replace(/"file:\/\/.+(\/.*\.html)"/, '"$1"') | ||
.replace(/"timeOffset":\s*\d+/, '"timeOffset": 0'); |
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.
m: I would prefer it if we made the redaction explicit here.
.replace(/"timeOffset":\s*\d+/, '"timeOffset": 0'); | |
.replace(/"timeOffset":\s*\d+/, '"timeOffset": [timeOffset]'); |
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.
With the redaction we now need to update snapshots :D
I just noticed that the last integration test I added in #7212 is flaky because of time offsets which can change in some CI runs. This PR normalizes the time offset to
[timeOffset]
in DOM snapshots to make sure this doesn't happen.