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.
For using the JavaScript client library, see js-client.md
⚠️ Important: Make commands (e.g., make -f .stoobly/services/Makefile test) are Docker-specific only. Local runtime uses CLI commands directly (e.g., stoobly-agent scaffold workflow up test).
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 supportstoobly-agentscaffoldappcreatemy-app--pluginplaywright# Create app with Cypress supportstoobly-agentscaffoldappcreatemy-app--plugincypress# Create app with both pluginsstoobly-agentscaffoldappcreatemy-app--pluginplaywright--plugincypress
Note: The files created depend on whether you use --runtime docker or --runtime local. For Docker-specific file details, see docker.md. For local runtime setup, see local.md.
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: The files you modify depend on your runtime:
Docker runtime: Modify entrypoint docker-compose.yml, configure script, and Playwright config. See docker.md for details.
Local runtime: Configure Playwright to use Stoobly's proxy via environment variables or config. See local.md for details.
Using JavaScript library: Use the Stoobly JavaScript client library with Playwright interceptor. See js-client.md for details.
Q: What files should I modify to add my Cypress tests?
A: The files you modify depend on your runtime:
Docker runtime: Modify entrypoint docker-compose.yml and Cypress config. See docker.md for details.
Local runtime: Configure Cypress to use Stoobly's proxy via environment variables or config. See local.md for details.
Using JavaScript library: Use the Stoobly JavaScript client library with Cypress interceptor. See js-client.md for details.
Q: How do I add custom npm packages for my tests?
A: The approach depends on your runtime:
Docker runtime: Use custom Docker images with PLAYWRIGHT_IMAGE or CYPRESS_IMAGE environment variables. See docker.md for details.
Local runtime: Install packages directly in your project using npm/yarn. No special configuration needed.
Q: How do I pass environment variables to my tests?
A: The approach depends on your runtime:
Docker runtime: Add environment variables in docker-compose.yml. See docker.md for details.
Local runtime: Set environment variables in your shell or use a .env file. See local.md for details.
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.
Docker runtime: See docker.md for Makefile commands.
Q: Which runtime should I use in CI/CD for E2E testing?
A: Docker is recommended for CI/CD as it provides consistent, isolated environments. Local runtime can also be used if your CI environment has Python and stoobly-agent installed.
Q: How do I test with different runtimes in CI/CD?
A: Create separate CI jobs, each using the desired runtime.
Example:
Complete Examples
Q: What's a complete example of setting up Playwright E2E tests?
A: Complete examples are available for both runtimes:
Docker runtime: See docker.md for a complete Docker-based example.
Local runtime: See local.md for local runtime setup guidance.
JavaScript library: See js-client.md for complete Playwright integration examples.
Q: How do I use the Stoobly JavaScript client library in my tests?
A: Install the stoobly package and use the Playwright or Cypress interceptor to record, mock, and test API requests directly from your test framework. See js-client.md for installation, integration, and complete examples.
Quick Reference
Key files to modify for E2E testing:
Docker runtime: See docker.md for file structure and customization details.
Local runtime: See local.md for file structure and customization details.
Common commands:
Docker runtime (Makefile commands): See docker.md for complete command reference.
Local runtime (CLI commands): See local.md for complete command reference.
# Create frontend service with only test workflow
stoobly-agent scaffold service create frontend \
--hostname app.local \
--port 80 \
--scheme http \
--workflow test
# .stoobly/services/frontend/test/init
#!/bin/bash
# Copy built frontend assets to public fixtures folder
# This makes the application available for E2E tests
cp -r ./dist/. .stoobly/fixtures/public/
# The frontend service will serve these static files during E2E tests
# .stoobly/services/entrypoint/test/configure (Docker)
# or .stoobly/services/<service>/test/configure (Local)
#!/bin/bash
# Replace dynamic user IDs with fixed test ID
stoobly-agent config rewrite set \
--pattern "https://api.local/users/.*" \
--method GET \
--mode test \
--type response_param \
--name "userId" \
--value "test-user-123"
# Replace timestamps
stoobly-agent config rewrite set \
--pattern "https://api.local/.*" \
--method GET --method POST \
--mode test \
--type response_param \
--name "timestamp" \
--value "2024-01-01T00:00:00Z"
# .github/workflows/test.yml
name: Test Different Runtimes
jobs:
test-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Test with Docker
run: |
make -f .stoobly/services/.Makefile test
make -f .stoobly/services/.Makefile test/down
test-local:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install stoobly-agent
run: pipx install stoobly-agent
- name: Test with Local
run: |
stoobly-agent scaffold workflow up test
stoobly-agent scaffold workflow down test