chore: make test more timing resilient (#1473)

This commit is contained in:
Marvin Hagemeister
2023-07-18 12:41:36 +02:00
committed by GitHub
parent f12c96ed45
commit 0fc6850d87
3 changed files with 88 additions and 95 deletions
+12 -8
View File
@@ -12,7 +12,11 @@ import {
puppeteer,
retry,
} from "./deps.ts";
import { startFreshServer } from "./test_utils.ts";
import {
clickWhenListenerReady,
startFreshServer,
waitForText,
} from "./test_utils.ts";
const assertFileExistence = async (files: string[], dirname: string) => {
for (const filePath of files) {
@@ -85,12 +89,12 @@ Deno.test({
let counterValue = await counter?.evaluate((el) => el.textContent);
assert(counterValue === "3");
const buttonPlus = await page.$(
await clickWhenListenerReady(
page,
"body > div > div > div > button:nth-child(3)",
);
await buttonPlus?.click();
await delay(100);
await waitForText(page, "body > div > div > div > p", "4");
counterValue = await counter?.evaluate((el) => el.textContent);
assert(counterValue === "4");
@@ -99,7 +103,7 @@ Deno.test({
await lines.cancel();
serverProcess.kill("SIGTERM");
await delay(100);
await serverProcess.status;
});
await retry(() => Deno.remove(tmpDirName, { recursive: true }));
@@ -183,7 +187,7 @@ Deno.test({
);
await buttonPlus?.click();
await delay(100);
await waitForText(page, "body > div > div > div > p", "4");
counterValue = await counter?.evaluate((el) => el.textContent);
assert(counterValue === "4");
@@ -192,7 +196,7 @@ Deno.test({
await lines.cancel();
serverProcess.kill("SIGTERM");
await delay(100);
await serverProcess.status;
});
await retry(() => Deno.remove(tmpDirName, { recursive: true }));
@@ -322,7 +326,7 @@ Deno.test({
await lines.cancel();
serverProcess.kill("SIGTERM");
await delay(100);
await serverProcess.status;
});
await retry(() => Deno.remove(tmpDirName, { recursive: true }));