chore: make test more timing resilient (#1473)
This commit is contained in:
+12
-8
@@ -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 }));
|
||||
|
||||
Reference in New Issue
Block a user