Agent Wranglers

End-to-end and browser tests Required

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.

Example

// playwright.config.js
export default {
  webServer: { command: 'npm run build && npm start', url: 'http://localhost:3000' },
  use: { baseURL: 'http://localhost:3000' },
};
# 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 uses the production build command and start command. A bug that only appears in the built app fails the browser suite.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers testing playbook: https://agentwranglers.se/playbook/testing/end-to-end-and-browser-tests/test-the-built-app.