Skip to content

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.

generate({format: "test"}) // Playwright regression test
generate({format: "reproduction"}) // Bug reproduction script
generate({format: "har", url: "/api"}) // HTTP Archive export
generate({format: "sarif"}) // Accessibility SARIF report
generate({format: "csp", mode: "strict"}) // Content Security Policy
generate({format: "sri"}) // Subresource Integrity hashes
generate({format: "pr_summary"}) // PR performance summary

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})
ParameterTypeDefaultDescription
test_namestringDerived from URLName for the test() block
base_urlstringCaptured originReplace origin in URLs for portability
assert_networkbooleanInclude waitForResponse + status code assertions
assert_no_errorsbooleanAssert consoleErrors.length === 0
assert_response_shapebooleanAssert response body structure matches (types only, never values)
  • 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 waitForResponse and 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]
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);
});

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})
ParameterTypeDefaultDescription
error_messagestringError message to include as context in the script
last_nnumberAllUse only the last N recorded actions
base_urlstringCaptured originReplace origin in URLs
include_screenshotsbooleanInsert page.screenshot() calls between steps
generate_fixturesbooleanGenerate fixture files from captured network data
visual_assertionsbooleanAdd toHaveScreenshot() assertions

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"})
ParameterTypeDescription
urlstringFilter by URL substring
methodstringFilter by HTTP method
status_minnumberMinimum status code
status_maxnumberMaximum status code
save_tostringFile path to save the HAR file

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"})
ParameterTypeDescription
scopestringCSS selector to limit audit scope
include_passesbooleanInclude passing rules (not just violations)
save_tostringFile 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})
ParameterTypeDescription
modestringStrictness: strict, moderate, or report_only
exclude_originsarrayOrigins to exclude from the generated CSP
include_report_uribooleanInclude a report-uri directive

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"]})
ParameterTypeDescription
resource_typesarrayFilter: script, stylesheet
originsarrayFilter by specific CDN origins

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)