E2E Testing

Stoobly Scaffold E2E Testing - Questions & Answers

Stoobly scaffold provides first-class support for E2E testing frameworks like Playwright and Cypress, enabling you to record, mock, and validate API interactions during your end-to-end tests.


Plugin Support

Q: What E2E testing frameworks does Stoobly support?

A: Stoobly supports Playwright and Cypress through the --plugin option when creating an app.

Example:

# Create app with Playwright support
stoobly-agent scaffold app create my-app --plugin playwright

# Create app with Cypress support
stoobly-agent scaffold app create my-app --plugin cypress

# Create app with both plugins
stoobly-agent scaffold app create my-app --plugin playwright --plugin cypress

Q: What files are created when I use the --plugin option?

A: When you specify a plugin, Stoobly creates a custom Dockerfile and entrypoint script in the entrypoint/test/ directory specifically configured for that E2E framework.

Files created for Playwright:

  • .stoobly/services/entrypoint/test/.Dockerfile.playwright - Stoobly-maintained base image that pulls in the stock Playwright image (override via PLAYWRIGHT_IMAGE)

  • .stoobly/services/entrypoint/test/.entrypoint.sh - Entrypoint script with CA certificate setup

  • .stoobly/services/entrypoint/test/docker-compose.yml - Docker compose configuration

  • .stoobly/services/entrypoint/test/configure - Stoobly configuration script

  • .stoobly/services/entrypoint/test/init - Initialization script

Files created for Cypress:

  • .stoobly/services/entrypoint/test/.Dockerfile.cypress - Stoobly-maintained base image that pulls in the stock Cypress image (override via CYPRESS_IMAGE)

  • .stoobly/services/entrypoint/test/docker-compose.yml - Docker compose configuration

  • .stoobly/services/entrypoint/test/configure - Stoobly configuration script

  • .stoobly/services/entrypoint/test/init - Initialization script


Initial Setup

Q: How do I create a scaffold script for E2E testing?

A: Create a shell script with only the scaffold creation commands. Include workflow commands as commented examples for reference.

Example:

Q: How do I scaffold an app for Playwright E2E testing?

A: Create an app with the --plugin playwright option to set up Playwright-specific configurations.

Example:

Q: How do I scaffold an app for Cypress E2E testing?

A: Create an app with the --plugin cypress option to set up Cypress-specific configurations.

Example:


Frontend Service Setup

Q: How do I set up a frontend service to serve static assets for E2E tests?

A: Frontend services typically only need the test workflow since they serve static assets from fixtures rather than recording or mocking requests. Create the service with --workflow test and modify the test/init script to copy your built application to the public fixtures folder.

Example:

Modify the init script to copy built assets:

Why only test workflow?

  • Frontend services serve static assets, not dynamic API responses

  • No need to record requests (no API logic to capture)

  • No need to mock responses (serving files, not making requests)

  • Test workflow is needed so E2E tests can request the application under test


Configuration Files

Q: What files should I modify to add my Playwright tests?

A: After scaffolding, you need to modify the entrypoint service docker-compose.yml to run your tests, the configure script to set up Stoobly rules, and your Playwright configuration to use the proxy. The example below shows how you would override the Stoobly-managed entrypoint.playwright service definition—only do this when you need additional customizations.

Example - Modify docker-compose.yml:

Example - Modify configure script:

Example - Create Playwright config:

Q: What files should I modify to add my Cypress tests?

A: For Cypress, modify the entrypoint service docker-compose.yml and Cypress configuration to work with Stoobly's proxy. As with Playwright, the example below overrides the managed entrypoint.cypress service definition—only override it when you need custom behavior.

Example - Modify docker-compose.yml:

Example - Create Cypress config:

Q: How do I add custom npm packages for my tests?

A: Don’t edit the Stoobly-maintained Dockerfiles (files beginning with a dot). Instead, point PLAYWRIGHT_IMAGE or CYPRESS_IMAGE at a custom image that already includes your dependencies.

Build those images however you like (e.g., start from mcr.microsoft.com/playwright or cypress/included and add packages), then reference them with the environment variable. Stoobly will use your custom image without touching the managed .Dockerfile.* files.

Q: How do I pass environment variables to my tests?

A: Add environment variables in the docker-compose.yml file under the environment section.

Example:


Running E2E Tests

Q: How do I record E2E test traffic?

A: Use the record workflow to capture all HTTP requests made during your E2E tests.

Example:

Q: How do I run E2E tests with mocked responses?

A: Use the mock workflow to run tests against recorded responses without hitting real APIs.

Example:

Q: How do I run E2E tests with response validation?

A: Use the test workflow to validate that responses match expected results.

Example:

Q: How do I run specific test files or suites?

A: Modify the command in docker-compose.yml to target specific tests.

Example for Playwright:

Example for Cypress:


Debugging

Q: How do I view test output and logs?

A: Use the logs command to see test execution output.

Example:

Q: How do I debug failing tests?

A: Enable headed mode and increase logging verbosity in the docker-compose.yml.

Example:

Q: How do I save test artifacts (screenshots, videos)?

A: Mount an artifacts directory to persist test outputs and configure your test framework to save artifacts.

Example:


Advanced Configuration

Q: How do I mount test fixtures and data?

A: Add volume mounts to share fixtures between host and container.

Example:

Q: How do I handle dynamic data in E2E tests?

A: Use Stoobly's rewrite rules to normalize dynamic values in the configure script.

Example:


Best Practices

Q: Should I record once and mock for all subsequent runs?

A: Yes, this is the recommended approach for fast, reliable E2E tests that don't depend on external APIs.

Example:

Q: How do I organize E2E tests by feature?

A: Create separate services or custom workflows for different test suites.

Example:


Complete Example

Q: What's a complete example of setting up Playwright E2E tests?

A: Here's a full example from scaffold to running tests.

Step 1: Scaffold the app

Step 2: Configure entrypoint docker-compose.yml

Step 3: Configure Stoobly rules

Step 4: Create Playwright config

Step 5: Create test

Step 6: Run tests


Quick Reference

Key files to modify for E2E testing:

Common commands:

Last updated

Was this helpful?