Skip to content

Commit

Permalink
Replace native fetch requests with playwright request to support olde…
Browse files Browse the repository at this point in the history
…r node versions
  • Loading branch information
raphiz committed Dec 12, 2023
1 parent 7ff5ec1 commit af19e86
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions clients/js/playwright/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +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

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

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

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

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

0 comments on commit af19e86

Please sign in to comment.