Skip to content

Commit

Permalink
Replace playwright request with node fetch ployfill to support playwr…
Browse files Browse the repository at this point in the history
…ight-ct
  • Loading branch information
raphiz committed Dec 13, 2023
1 parent af19e86 commit a5fb413
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions clients/js/playwright/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { existsSync, mkdirSync } from "fs";
import fs from "fs/promises";
import {request} from '@playwright/test'; // Dependency to playwright is implied by using this project
import fetch from 'node-fetch';

const appDir = process.env.PWD;
const MODE = process.env.PIXELPACT_MODE ?? "verify";
Expand Down Expand Up @@ -45,10 +45,9 @@ async function recordReferenceImage(mHtml, page, fileNamePrefix, options) {
...options,
};

const requestContext = await request.newContext()
const response = await requestContext.fetch(`${SERVER_URL}/render`, {
const response = await fetch(`${SERVER_URL}/render`, {
method: "post",
data: JSON.stringify(body),
body: JSON.stringify(body),
headers: { "Content-Type": "application/json" },
});

Expand All @@ -66,10 +65,9 @@ async function verfiy(page, testInfo, fileNamePrefix, mhtml, options) {
...options,
};

const requestContext = await request.newContext()
const response = await requestContext.fetch(SERVER_URL + "/check", {
const response = await fetch(SERVER_URL + "/check", {
method: "post",
data: JSON.stringify(body),
body: JSON.stringify(body),
headers: { "Content-Type": "application/json" },
});
const result = await response.json();
Expand Down

0 comments on commit a5fb413

Please sign in to comment.