Skip to content

Commit 0cf8c4e

Browse files
authored
chore: unflake tracing test (#1822)
1 parent 1fb593e commit 0cf8c4e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

playwright/src/test/java/com/microsoft/playwright/TestChromiumTracing.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,21 @@ void shouldCreateDirectoriesAsNeeded(@TempDir Path tempDir) {
5757
}
5858
}
5959

60+
private static void rafraf(Page page) {
61+
int count = 2;
62+
for (int i = 0; i < count; i++) {
63+
page.evaluate("() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f)))");
64+
}
65+
}
66+
6067
@Test
6168
void shouldRunWithCustomCategoriesIfProvided(@TempDir Path tempDir) throws IOException {
6269
try (Page page = browser.newPage()) {
6370
Path outputTraceFile = tempDir.resolve("trace.json");
6471
browser.startTracing(page, new Browser.StartTracingOptions()
6572
.setPath(outputTraceFile)
6673
.setCategories(asList("disabled-by-default-cc.debug")));
67-
page.evaluate("() => 1 + 1");
74+
rafraf(page);
6875
browser.stopTracing();
6976
try (FileReader fileReader = new FileReader(outputTraceFile.toFile())) {
7077
JsonObject traceJson = new Gson().fromJson(fileReader, JsonObject.class);
@@ -75,7 +82,7 @@ void shouldRunWithCustomCategoriesIfProvided(@TempDir Path tempDir) throws IOExc
7582
boolean hasTraceEvents = traceJson.getAsJsonArray("traceEvents").asList().stream()
7683
.anyMatch(event -> {
7784
JsonObject eventObj = (JsonObject) event;
78-
return eventObj.has("cat") &&
85+
return eventObj.has("cat") &&
7986
eventObj.get("cat").getAsString().equals("disabled-by-default-cc.debug");
8087
});
8188
assertTrue(hasTraceConfig || hasTraceEvents);

0 commit comments

Comments
 (0)