
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
jest-puppeteer-performance
Advanced tools
Automated UI Performance Testing with Jest and Puppeteer
Automated UI Performance Testing with Jest and Puppeteer
This project has a peer dependency on puppeteer
and is intended to be used with jest
test runner.
Jest: https://github.com/facebook/jest
Puppeteer: https://github.com/GoogleChrome/puppeteer
npm install jest-puppeteer-performance puppeteer jest
NOTE: We do not install puppeteer
or jest
because you will need to install them under your own project in order to use them in your source files and with your own tests. jest-puppeteer-performance
is not intended to take on the responsibility of providing a test runner, or headless browser. This allows us to keep our package smaller and avoid installing multiple versions of these dependencies.
This module exports one function analyzePerformance()
. Here is an example of how to use it with the default options in a test.
import * as puppeteer from 'puppeteer';
import { analyzePerformance } from 'jest-puppeteer-performance';
describe('Performance Test', async () => {
let page;
let browser;
beforeAll(async () => {
browser = await puppeteer.launch({headless: false});
page = await browser.newPage();
await page.goto('http://example.net/example.html');
});
afterAll(async () => {
await browser.close();
});
it('Should be performant', async () => {
await analyzePerformance(page);
});
});
MetricsOptions
is an object with the following options:
exclude
: Array of metrics to exclude from measurements.minSamples
: Minimum number of samples required before asserting.maxSamples
: Maximum number of samples to keep.thresholds
: An object desribing how to analyze each metric, indexed by metric keyname. The *
special key applies to all metrics not specified separately.thresholds[key].limit
: The limit to apply to the threshold method (number of standard deviations, percent increase, or absolute value).thresholds[key].type
: The type of threshold method to use when evaluating the specified metric.{
exclude: [Metrics.KEYS.Timestamp],
minSamples: 5,
maxSamples: 20,
thresholds: {
'*': {
limit: 2,
type: Metrics.THRESHOLD.StDev
}
}
}
Absolute
: Absolute ValuePercentage
: PercentageStDev
: Standard DeviationTimestamp
Documents
Frames
JSEventListeners
Nodes
LayoutCount
RecalcStyleCount
LayoutDuration
RecalcStyleDuration
ScriptDuration
TaskDuration
JSHeapUsedSize
JSHeapTotalSize
appcacheTime
connectTime
domReadyTime
firstPaint
firstPaintTime
initDomTreeTime
loadEventTime
loadTime
lookupDomainTime
readyStart
redirectTime
requestTime
unloadEventTime
We have provided a script for submitting results to New Relic. You will find the reporter under the contrib
namespace.
import * as puppeteer from 'puppeteer';
import { analyzePerformance, performanceEvents, contrib } from 'jest-puppeteer-performance';
let nrAPIKey = 'abcdefABCDEF012345-wXyZ';
let nrCollectorURI = 'https://insights-collector.newrelic.com/v1/accounts/123456/events';
describe('Performance Test', async () => {
let page;
let browser;
let newrelic;
beforeAll(async () => {
newrelic = new contrib.NewRelic(performanceEvents, nrAPIKey, nrCollectorURI);
browser = await puppeteer.launch({headless: false});
page = await browser.newPage();
await page.goto('http://example.net/example.html');
});
afterAll(async () => {
await browser.close();
await newrelic.send();
});
it('Should be performant', async () => {
await analyzePerformance(page);
});
});
FAQs
Automated UI Performance Testing with Jest and Puppeteer
The npm package jest-puppeteer-performance receives a total of 0 weekly downloads. As such, jest-puppeteer-performance popularity was classified as not popular.
We found that jest-puppeteer-performance demonstrated a not healthy version release cadence and project activity because the last version was released 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
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.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.