
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
playwright-advanced-har
Advanced tools
Playwright-advanced-har is a library that allows various use-cases for network record-and-playback, including:
npm install playwright-advanced-har
The playwright-advanced-har provides a playwright fixture called advancedRouteFromHAR.
Here is an example of using a custom matcher to ignore 500 status code errors:
import { test, defaultMatcher, customMatcher } from "playwright-advanced-har";
test("don't route responses that have errors", async ({ page, advancedRouteFromHAR }) => {
await advancedRouteFromHAR("tests/har/first-has-error.har", {
matcher: (request, entry) => {
if (entry.response.status >= 500 && entry.response.status < 600) {
return -1;
}
return defaultMatcher(request, entry);
},
});
await page.goto("https://noam-gaash.co.il");
await page.getByText("Hello World").waitFor();
});
The matcher arguments is a callback function that receives the request and the HAR entry and returns a number.
The number indicates how "good" the response is. Negative numbers (such as -1) tells the router to ignore the entry, while positive numbers indicates the entry is a qualified candidate to be routed from.
ignoring port numbers:
test("ignore port number", async ({ page, advancedRouteFromHAR }) => {
await advancedRouteFromHAR("tests/har/different-port.har", {
matcher: customMatcher({
urlComparator(a, b) {
a = a.replace(/:\d+/, "");
b = b.replace(/:\d+/, "");
return a === b;
},
}),
});
await page.goto("https://noam-gaash.co.il");
await page.getByText("from different port").waitFor();
});
choosing arbitrary responses:
test("pick arbirtrary response", async ({ page, advancedRouteFromHAR }) => {
// good when you're testing a long polling requests
await advancedRouteFromHAR("tests/har/differentNumbers.har", {
matcher: customMatcher({
scoring() {
return Math.random();
},
}),
});
await page.goto("https://noam-gaash.co.il");
await page.getByText("1234").waitFor();
});
apply post-proccessing on the chosen HAR entry:
test("get the largest number... squared!", async ({ page, advancedRouteFromHAR }) => {
// the file contains 3 responses - 42, 1234, 5
await advancedRouteFromHAR("tests/har/differentNumbers.har", {
matcher: {
postProcess(entry) {
entry.response.content.text = (parseInt(entry.response.content.text || "0") ** 2).toString();
return entry;
},
matchFunction: customMatcher({
scoring: (request, entry) => parseInt(entry.response.content.text || "0"),
}),
}
});
await page.goto("https://noam-gaash.co.il");
await page.getByText((1234**2).toString()).waitFor();
});
for more examples, please see our tests directory
Contributions are welcome!
Please open an issue with a use-case before opening a PR, so we can discuss it. Make sure you add tests and run npm run test before commiting.
npm install
npm test
FAQs
Advanced HAR routing for Playwright
The npm package playwright-advanced-har receives a total of 8,097 weekly downloads. As such, playwright-advanced-har popularity was classified as popular.
We found that playwright-advanced-har demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.