Skip to content

Commit

Permalink
Merge pull request #94 from the-markup/fix-tests
Browse files Browse the repository at this point in the history
Fix Keylogging Tests
  • Loading branch information
BatMiles authored Jul 23, 2024
2 parents 0d0fb65 + 6e603c4 commit a7356d3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions __tests__/key-logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]", name: "email" },
{
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a7356d3

Please sign in to comment.