Agent Wranglers

TST-20Required

Run browser tests against the production build

Run end-to-end tests against the same build you deploy, with production settings, not against a development server.

How to do it

Build the app once, start it like production, and point the browser tests at it. Development servers skip minification, caching headers and security policies, so they hide bugs. Let the runner start the app and wait until it answers, such as with Playwright's webServer option or a pytest session fixture. Also call the built app over HTTP without a browser. For a website, fetch every page and check titles, canonical links, structured data, security headers, status codes and redirects. Audit every page of that build as Audit every page in a browser before release says.

Examples

JavaScript example

// playwright.config.js
export default {
  webServer: { command: 'npm run build && npm start', url: 'http://localhost:3000' },
  use: { baseURL: 'http://localhost:3000' },
};

Python example

# pytest: start the production build once, then test it over HTTP
@pytest.fixture(scope="session")
def base_url():
    server = subprocess.Popen(["gunicorn", "shop.wsgi", "--bind", "127.0.0.1:8000"])
    wait_until_answers("http://127.0.0.1:8000/healthz")
    yield "http://127.0.0.1:8000"
    server.terminate()

How to check

The test job runs the production build and start commands, never a development server such as vite dev or npm run dev. A bug that only appears in the built app fails the browser suite.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/testing/end-to-end-and-browser-tests/test-the-built-app">Agent Wranglers testing playbook</a>. In code you write, add a comment next to it with the same link.