
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@loveholidays/preact-perf-metrics
Advanced tools
A performance-testing tool for your preact based app
This utility allows you to instrument your preact application bundle, and to write performance tests using playwright to assert on the framework activity (rerenders, unmountings, etc) during an interaction.
Using this tool, you can ensure that performance doesn't regress unintentionally.
Know the story behind the tool in our Blog Post, and check the /example code for practical information.
Made with ❤️ by loveholidays.com
See an example application in the /example subdirectory.
npm install @loveholidays/preact-perf-metrics
import { setup } from "@loveholidays/preact-perf-metrics/lib/setup"
// ... somewhere in your app entry-point
setup();
[!NOTE] you might want to call
setup()
only in a testing environment (and not in the production build) because the instrumentation adds some overhead. Similarly to what you would do withpreact/debug
for the devtools.
This extends the expect
function to support the libraries' custom matchers.
import { expect } from '@playwright/test';
import { extension } from '@loveholidays/preact-perf-metrics';
expect.extend(extension);
[!NOTE] This can also be done on the test file itself or in another file (see playwright-custom-matchers docs)
Write performance tests using reset()
(reset the counters) and the custom matchers (toPerform()
, toRerender()
)
import { expect, test } from '@playwright/test';
import { reset } from '@loveholidays/preact-perf-metrics';
test("...", await ({page}) => {
await page.goto('...');
// prepare: clear the counters
await reset(page); /
// action
await page.getByText('Button').click();
// test: use of custom matcher `toPerform`
await expect(page).toPerform({ nodesRendered: 1, renderPhases: 1 });
})
The API can be divided in two:
setup()
,reset()
, expect.toPerform()
, and expect.toRerender()
setup()
Instruments the application to update the counters in window.__PREACT_PERF_METRICS__
upon any preact internal activity (renders, unmounting, etc).
reset()
Playwright utility to reset all the counters (accummulators) to zero. Used to set the beginning of a measurement.
expect().toPerform(...)
Playwright Custom matcher to assert on the framework activity during an interaction.
The parameter to assert is an object with one or many of the following keys:
interface Counters {
nodesRendered?: number;
renderPhases?: number;
nodesUnmmouted?: number;
}
Example:
await reset();
await page.locator('.counter').click();
await expect(page).toPerform({ nodesRendered: 1 });
expect().toRerender(...)
Playwright Custom matcher to assert on the list of nodes rendered during an interaction.
The parameter to assert is an array of strings, with the names of the preact-nodes involved:
Example:
await reset();
await page.locator('.counter').click();
await expect(page).toRerender(["MyCounterPage", "Button"]);
Please see our contributing guidelines
MIT
1.1.0
FAQs
Preact+Playwright performance test
The npm package @loveholidays/preact-perf-metrics receives a total of 466 weekly downloads. As such, @loveholidays/preact-perf-metrics popularity was classified as not popular.
We found that @loveholidays/preact-perf-metrics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 60 open source maintainers 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.