From 6e603c40692c7dfa2de96a348c4f853d40defe4b Mon Sep 17 00:00:00 2001 From: Miles Hilton Date: Tue, 23 Jul 2024 09:44:26 -0400 Subject: [PATCH] fixing tests --- __tests__/key-logging.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/__tests__/key-logging.ts b/__tests__/key-logging.ts index 7597b87..3791493 100644 --- a/__tests__/key-logging.ts +++ b/__tests__/key-logging.ts @@ -7,6 +7,8 @@ import { Global } from "../src/types"; declare var global: Global; +const sleep = ms => new Promise(res => setTimeout(res, ms)); + const INPUT_VALUES_RESULT = [ { type: "email", value: "blacklight-headless@themarkup.org", name: "email" }, { @@ -673,7 +675,7 @@ describe("KeyLogging", () => { const testUrl = `${global.__DEV_SERVER__}/input-form.html`; await page.goto(testUrl, { timeout: 10000 }); await fillForms(page); - await page.waitForTimeout(2000); + await sleep(2000); const inputValues: any = await page.evaluate(async () => { return new Promise((res, rej) => { @@ -702,9 +704,9 @@ describe("KeyLogging", () => { await setupKeyLoggingInspector(page, eventHandler); await page.goto(testUrl, { waitUntil: "networkidle2" }); - await page.waitForTimeout(1000); + await sleep(1000); await fillForms(page); - await page.waitForTimeout(100); + await sleep(100); await page.close(); // console.log(rows); expect(rows.filter(r => r.type === "KeyLogging").sort()).toEqual( @@ -779,9 +781,9 @@ describe("KeyLogging", () => { }; await setupKeyLoggingInspector(page, eventHandler); await page.goto(testUrl, { waitUntil: "networkidle2" }); - await page.waitForTimeout(1000); + await sleep(1000); await fillForms(page); - await page.waitForTimeout(100); + await sleep(100); await page.close(); expect(rows.filter(r => r.type === "KeyLogging").sort()).toEqual( DATA_EXFILTRATION_MIXED.sort()