Skip to content

Commit aa1d4e5

Browse files
authored
test(replay): Normalize time offset in DOM snapshots (#7219)
Normalize timeOffset entry in snapshots to avoid flakiness
1 parent e44600f commit aa1d4e5

13 files changed

+16
-13
lines changed

packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-1-snap-incremental

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"x": 41,
77
"y": 18,
88
"id": 9,
9-
"timeOffset": 0
9+
"timeOffset": [timeOffset]
1010
}
1111
]
1212
},

packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-1-snap-incremental-chromium

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"x": 41,
77
"y": 18,
88
"id": 9,
9-
"timeOffset": 0
9+
"timeOffset": [timeOffset]
1010
}
1111
]
1212
},

packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-3-snap-incremental

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"x": 41,
77
"y": 18,
88
"id": 9,
9-
"timeOffset": 0
9+
"timeOffset": [timeOffset]
1010
}
1111
]
1212
},

packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-3-snap-incremental-chromium

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"x": 41,
77
"y": 18,
88
"id": 9,
9-
"timeOffset": 0
9+
"timeOffset": [timeOffset]
1010
}
1111
]
1212
},

packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-5-snap-incremental

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"x": 41,
77
"y": 90,
88
"id": 12,
9-
"timeOffset": 0
9+
"timeOffset": [timeOffset]
1010
}
1111
]
1212
},

packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-5-snap-incremental-chromium

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"x": 41,
77
"y": 90,
88
"id": 12,
9-
"timeOffset": 0
9+
"timeOffset": [timeOffset]
1010
}
1111
]
1212
},

packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-6-snap-incremental

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"x": 157,
77
"y": 90,
88
"id": 15,
9-
"timeOffset": 0
9+
"timeOffset": [timeOffset]
1010
}
1111
]
1212
},

packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-6-snap-incremental-chromium

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"x": 157,
77
"y": 90,
88
"id": 15,
9-
"timeOffset": 0
9+
"timeOffset": [timeOffset]
1010
}
1111
]
1212
},

packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-7-snap-incremental

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"x": 41,
77
"y": 90,
88
"id": 12,
9-
"timeOffset": 0
9+
"timeOffset": [timeOffset]
1010
}
1111
]
1212
},

packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-7-snap-incremental-chromium

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"x": 41,
77
"y": 90,
88
"id": 12,
9-
"timeOffset": 0
9+
"timeOffset": [timeOffset]
1010
}
1111
]
1212
},

packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-9-snap-incremental

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"x": 41,
77
"y": 18,
88
"id": 9,
9-
"timeOffset": 0
9+
"timeOffset": [timeOffset]
1010
}
1111
]
1212
},

packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-9-snap-incremental-chromium

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"x": 41,
77
"y": 18,
88
"id": 9,
9-
"timeOffset": 0
9+
"timeOffset": [timeOffset]
1010
}
1111
]
1212
},

packages/integration-tests/utils/replayHelpers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,12 @@ export function shouldSkipReplayTest(): boolean {
214214
* Takes a replay recording payload and returns a normalized string representation.
215215
* This is necessary because the DOM snapshots contain absolute paths to other HTML
216216
* files which break the tests on different machines.
217+
* Also, we need to normalize any time offsets as they can vary and cause flakes.
217218
*/
218219
export function normalize(obj: unknown): string {
219220
const rawString = JSON.stringify(obj, null, 2);
220-
const normalizedString = rawString.replace(/"file:\/\/.+(\/.*\.html)"/g, '"$1"');
221+
const normalizedString = rawString
222+
.replace(/"file:\/\/.+(\/.*\.html)"/gm, '"$1"')
223+
.replace(/"timeOffset":\s*-?\d+/gm, '"timeOffset": [timeOffset]');
221224
return normalizedString;
222225
}

0 commit comments

Comments
 (0)