generate() — Create Artifacts
The generate tool creates production-ready artifacts from captured browser data. Tests, reproduction scripts, reports, and exports — all generated from real browser sessions.
Quick Reference
Section titled “Quick Reference”generate({format: "test"}) // Playwright regression testgenerate({format: "reproduction"}) // Bug reproduction scriptgenerate({format: "har", url: "/api"}) // HTTP Archive exportgenerate({format: "sarif"}) // Accessibility SARIF reportgenerate({format: "csp", mode: "strict"}) // Content Security Policygenerate({format: "sri"}) // Subresource Integrity hashesgenerate({format: "pr_summary"}) // PR performance summarytest — Playwright Regression Tests
Section titled “test — Playwright Regression Tests”Generates a complete Playwright test from the current browser session. Captures user actions, correlates them with API calls, and produces tests with real assertions — not just click replay.
generate({format: "test"})
generate({format: "test", test_name: "guest-checkout", base_url: "http://localhost:3000", assert_network: true, assert_no_errors: true, assert_response_shape: true})| Parameter | Type | Default | Description |
|---|---|---|---|
test_name | string | Derived from URL | Name for the test() block |
base_url | string | Captured origin | Replace origin in URLs for portability |
assert_network | boolean | — | Include waitForResponse + status code assertions |
assert_no_errors | boolean | — | Assert consoleErrors.length === 0 |
assert_response_shape | boolean | — | Assert response body structure matches (types only, never values) |
What the output includes
Section titled “What the output includes”- User actions translated to Playwright commands (
click,fill,getByRole, etc.) - Multi-strategy selectors prioritized:
data-testid> ARIA role > label > text > ID > CSS - Network assertions with
waitForResponseand status code checks - Response shape validation — field names and types, never actual values
- Console error collection — asserts zero errors during the flow
- Password redaction — passwords replaced with
[user-provided]
Example output
Section titled “Example output”import { test, expect } from '@playwright/test';
test('submit-form flow', async ({ page }) => { const consoleErrors = []; page.on('console', msg => { if (msg.type() === 'error') consoleErrors.push(msg.text()); });
await page.goto('http://localhost:3000/login'); await page.getByLabel('Email').fill('user@example.com'); await page.getByLabel('Password').fill('[user-provided]');
const loginResp = page.waitForResponse(r => r.url().includes('/api/auth/login')); await page.getByRole('button', { name: 'Sign In' }).click(); const resp = await loginResp; expect(resp.status()).toBe(200);
expect(consoleErrors).toHaveLength(0);});reproduction — Bug Reproduction Scripts
Section titled “reproduction — Bug Reproduction Scripts”Generates a Playwright script that reproduces the user’s actions leading up to a bug. Unlike test, this focuses on replaying the exact sequence rather than asserting outcomes.
generate({format: "reproduction"})
generate({format: "reproduction", error_message: "TypeError: Cannot read property 'id' of undefined", last_n: 10, base_url: "http://localhost:3000", include_screenshots: true})| Parameter | Type | Default | Description |
|---|---|---|---|
error_message | string | — | Error message to include as context in the script |
last_n | number | All | Use only the last N recorded actions |
base_url | string | Captured origin | Replace origin in URLs |
include_screenshots | boolean | — | Insert page.screenshot() calls between steps |
generate_fixtures | boolean | — | Generate fixture files from captured network data |
visual_assertions | boolean | — | Add toHaveScreenshot() assertions |
har — HTTP Archive Export
Section titled “har — HTTP Archive Export”Exports captured network traffic in HAR 1.2 format. HAR files can be imported into Chrome DevTools, Charles Proxy, or any HAR viewer for analysis.
generate({format: "har"})
generate({format: "har", url: "/api", method: "POST", status_min: 400, save_to: "/tmp/debug.har"})| Parameter | Type | Description |
|---|---|---|
url | string | Filter by URL substring |
method | string | Filter by HTTP method |
status_min | number | Minimum status code |
status_max | number | Maximum status code |
save_to | string | File path to save the HAR file |
sarif — Accessibility SARIF Report
Section titled “sarif — Accessibility SARIF Report”Exports accessibility audit results in SARIF format (Static Analysis Results Interchange Format). SARIF files integrate with GitHub Code Scanning, VS Code, and CI/CD pipelines.
generate({format: "sarif"})
generate({format: "sarif", scope: "#main-content", include_passes: true, save_to: "/tmp/a11y.sarif"})| Parameter | Type | Description |
|---|---|---|
scope | string | CSS selector to limit audit scope |
include_passes | boolean | Include passing rules (not just violations) |
save_to | string | File path to save the SARIF file |
csp — Content Security Policy Generation
Section titled “csp — Content Security Policy Generation”Generates a Content Security Policy header from observed network traffic. Gasoline sees which origins your page loads resources from and produces a CSP that allows exactly those origins.
generate({format: "csp"})
generate({format: "csp", mode: "strict", exclude_origins: ["https://analytics.google.com"], include_report_uri: true})| Parameter | Type | Description |
|---|---|---|
mode | string | Strictness: strict, moderate, or report_only |
exclude_origins | array | Origins to exclude from the generated CSP |
include_report_uri | boolean | Include a report-uri directive |
sri — Subresource Integrity Hashes
Section titled “sri — Subresource Integrity Hashes”Generates SRI hashes for external scripts and stylesheets. SRI ensures that fetched resources haven’t been tampered with.
generate({format: "sri"})
generate({format: "sri", resource_types: ["script"], origins: ["https://cdn.example.com"]})| Parameter | Type | Description |
|---|---|---|
resource_types | array | Filter: script, stylesheet |
origins | array | Filter by specific CDN origins |
pr_summary — PR Performance Summary
Section titled “pr_summary — PR Performance Summary”Generates a performance impact summary suitable for pull request descriptions. Compares before/after metrics and highlights regressions or improvements.
generate({format: "pr_summary"})No additional parameters. Uses the current performance snapshot data.
Output includes:
- Web Vitals comparison (before/after)
- Regression/improvement verdicts
- Network request count changes
- Bundle size impact (if measurable)