4.6 KiB
E2E
This package contains the repository-level end-to-end tests for Dify.
This file is the canonical package guide for e2e/. Keep detailed workflow, architecture, debugging, and reporting documentation here. Keep README.md as a minimal pointer to this file so the two documents do not drift.
The suite uses Cucumber for scenario definitions and Playwright as the browser execution layer.
It tests:
- backend API started from source
- frontend served from the production artifact
- middleware services started from Docker
Prerequisites
- Node.js
^22.22.1 pnpmuv- Docker
Install Playwright browsers once:
cd e2e
pnpm install
pnpm e2e:install
pnpm check
Use pnpm check as the default local verification step after editing E2E TypeScript, Cucumber support code, or feature glue. It runs formatting, linting, and type checks for this package.
Common commands:
# authenticated-only regression (default excludes @fresh)
# expects backend API, frontend artifact, and middleware stack to already be running
pnpm e2e
# full reset + fresh install + authenticated scenarios
# starts required middleware/dependencies for you
pnpm e2e:full
# run a tagged subset
pnpm e2e -- --tags @smoke
# headed browser
pnpm e2e:headed -- --tags @smoke
# slow down browser actions for local debugging
E2E_SLOW_MO=500 pnpm e2e:headed -- --tags @smoke
Frontend artifact behavior:
- if
web/.next/BUILD_IDexists, E2E reuses the existing build by default - if you set
E2E_FORCE_WEB_BUILD=1, E2E rebuilds the frontend before starting it
Lifecycle
flowchart TD
A["Start E2E run"] --> B["run-cucumber.ts orchestrates setup/API/frontend"]
B --> C["support/web-server.ts starts or reuses frontend directly"]
C --> D["Cucumber loads config, steps, and support modules"]
D --> E["BeforeAll bootstraps shared auth state via /install"]
E --> F{"Which command is running?"}
F -->|`pnpm e2e`| G["Run config default tags: not @fresh and not @skip"]
F -->|`pnpm e2e:full*`| H["Override tags to not @skip"]
G --> I["Per-scenario BrowserContext from shared browser"]
H --> I
I --> J["Failure artifacts written to cucumber-report/artifacts"]
Ownership is split like this:
scripts/setup.tsis the single environment entrypoint for reset, middleware, backend, and frontend startuprun-cucumber.tsorchestrates the E2E run and Cucumber invocationsupport/web-server.tsmanages frontend reuse, startup, readiness, and shutdownfeatures/support/hooks.tsmanages auth bootstrap, scenario lifecycle, and diagnosticsfeatures/support/world.tsowns per-scenario typed contextfeatures/step-definitions/holds domain-oriented glue so the official VS Code Cucumber plugin works with default conventions whene2e/is opened as the workspace root
Package layout:
features/: Gherkin scenarios grouped by capabilityfeatures/step-definitions/: domain-oriented step definitionsfeatures/support/hooks.ts: suite lifecycle, auth-state bootstrap, diagnosticsfeatures/support/world.ts: shared scenario contextsupport/web-server.ts: typed frontend startup/reuse logicscripts/setup.ts: reset and service lifecycle commandsscripts/run-cucumber.ts: Cucumber orchestration entrypoint
Behavior depends on instance state:
- uninitialized instance: completes install and stores authenticated state
- initialized instance: signs in and reuses authenticated state
Because of that, the @fresh install scenario only runs in the pnpm e2e:full* flows. The default pnpm e2e* flows exclude @fresh via Cucumber config tags so they can be re-run against an already initialized instance.
Reset all persisted E2E state:
pnpm e2e:reset
This removes:
docker/volumes/db/datadocker/volumes/redis/datadocker/volumes/weaviatedocker/volumes/plugin_daemone2e/.authe2e/.logse2e/cucumber-report
Start the full middleware stack:
pnpm e2e:middleware:up
Stop the full middleware stack:
pnpm e2e:middleware:down
The middleware stack includes:
- PostgreSQL
- Redis
- Weaviate
- Sandbox
- SSRF proxy
- Plugin daemon
Fresh install verification:
pnpm e2e:full
Run the Cucumber suite against an already running middleware stack:
pnpm e2e:middleware:up
pnpm e2e
pnpm e2e:middleware:down
Artifacts and diagnostics:
cucumber-report/report.html: HTML reportcucumber-report/report.json: JSON reportcucumber-report/artifacts/: failure screenshots and HTML captures.logs/cucumber-api.log: backend startup log.logs/cucumber-web.log: frontend startup log
Open the HTML report locally with:
open cucumber-report/report.html