Skip to content

test(replay): Normalize time offset in DOM snapshots #7219

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 3 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"x": 41,
"y": 18,
"id": 9,
"timeOffset": 0
"timeOffset": [timeOffset]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"x": 41,
"y": 18,
"id": 9,
"timeOffset": 0
"timeOffset": [timeOffset]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"x": 41,
"y": 18,
"id": 9,
"timeOffset": 0
"timeOffset": [timeOffset]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"x": 41,
"y": 18,
"id": 9,
"timeOffset": 0
"timeOffset": [timeOffset]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"x": 41,
"y": 90,
"id": 12,
"timeOffset": 0
"timeOffset": [timeOffset]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"x": 41,
"y": 90,
"id": 12,
"timeOffset": 0
"timeOffset": [timeOffset]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"x": 157,
"y": 90,
"id": 15,
"timeOffset": 0
"timeOffset": [timeOffset]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"x": 157,
"y": 90,
"id": 15,
"timeOffset": 0
"timeOffset": [timeOffset]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"x": 41,
"y": 90,
"id": 12,
"timeOffset": 0
"timeOffset": [timeOffset]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"x": 41,
"y": 90,
"id": 12,
"timeOffset": 0
"timeOffset": [timeOffset]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"x": 41,
"y": 18,
"id": 9,
"timeOffset": 0
"timeOffset": [timeOffset]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"x": 41,
"y": 18,
"id": 9,
"timeOffset": 0
"timeOffset": [timeOffset]
}
]
},
Expand Down
5 changes: 4 additions & 1 deletion packages/integration-tests/utils/replayHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,12 @@ export function shouldSkipReplayTest(): boolean {
* Takes a replay recording payload and returns a normalized string representation.
* This is necessary because the DOM snapshots contain absolute paths to other HTML
* files which break the tests on different machines.
* Also, we need to normalize any time offsets as they can vary and cause flakes.
*/
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)"/gm, '"$1"')
.replace(/"timeOffset":\s*-?\d+/gm, '"timeOffset": [timeOffset]');
return normalizedString;
}