Skip to content

Commit

Permalink
refactor: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
NoamGaash committed Feb 20, 2024
1 parent fd74278 commit 4766346
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"rules": {
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double"],
"semi": ["error", "always"]
"semi": ["error", "always"],
"no-empty-pattern": "off"
}
}
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const test = base.extend<{
const originalRouteFromHAR = page.routeFromHAR.bind(page);
const advancedRouteFromHAR: AdvancedRouteFromHAR = async (filename, options) => {
if (options?.update) {
const {matcher} = options
const {matcher} = options;
if (matcher && "postProcess" in matcher) {
await page.route(options.url || /.*/, async (route, request) => {
const resp = await route.fetch();
Expand All @@ -26,7 +26,7 @@ export const test = base.extend<{
headers: Object.fromEntries(response.headers.map((header) => [header.name, header.value])),
body: await parseContent(response.content, path.dirname(filename)),
});
})
});
}
// on update, we want to record the HAR just like the original playwright method
return originalRouteFromHAR(filename, {
Expand Down
5 changes: 2 additions & 3 deletions tests/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { describe } from "node:test";
import { test } from "../lib/index";

test("record", async ({ page, advancedRouteFromHAR }) => {
Expand All @@ -17,7 +16,7 @@ test("record test with a joke", async ({ page, advancedRouteFromHAR }) => {
});
await page.goto("https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,sexist,explicit");
await page.close();
})
});

test("record test with a joke and postprocess", async ({ page, advancedRouteFromHAR }) => {
await advancedRouteFromHAR("tests/har/temp/joke-postprocess.har", {
Expand All @@ -33,4 +32,4 @@ test("record test with a joke and postprocess", async ({ page, advancedRouteFrom
await page.goto("https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,sexist,explicit");
await page.waitForSelector("text=This is a joke");
await page.close();
})
});
6 changes: 3 additions & 3 deletions tests/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ test("test a joke recording with postprocess", async ({ page, advancedRouteFromH
await page.goto("https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,sexist,explicit");
await page.waitForSelector("text=This is a joke");
await page.close();
})
});

test("test a joke recording with different postprocess that was not recorded", async ({ page, advancedRouteFromHAR }) => {
await advancedRouteFromHAR("tests/har/temp/joke-postprocess.har", {
Expand All @@ -201,7 +201,7 @@ test("test a joke recording with different postprocess that was not recorded", a
await page.goto("https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,sexist,explicit");
await page.waitForSelector("text=This is not a joke");
await page.close();
})
});

test("test a postprocess that change only part of the output", async ({ page, advancedRouteFromHAR }) => {
await advancedRouteFromHAR("tests/har/temp/joke-postprocess.har", {
Expand All @@ -225,6 +225,6 @@ test("test a postprocess that change only part of the output", async ({ page, ad
expect(flags.custom).toBe(true);
expect(flags.nsfw).toBe(false);
await page.close();
})
});


0 comments on commit 4766346

Please sign in to comment.