.agents/skills/e2e-cucumber-playwright
stars:148605
forks:23425
watches:818
last updated:2026-07-12 21:10:27
Dify E2E Cucumber + Playwright
Use this skill for Dify's repository-level E2E suite in e2e/. Use e2e/AGENTS.md as the canonical package guide for local architecture and conventions, then read any feature-scoped AGENTS.md that owns the target area. Apply Playwright/Cucumber best practices only where they fit the current suite.
Scope
- Use this skill for
.featurefiles, Cucumber step definitions,DifyWorld, hooks, tags, and E2E review work undere2e/. - Do not use this skill for Vitest or React Testing Library work under
web/; usefrontend-testinginstead. - Do not use this skill for backend test or API review tasks under
api/.
Read Order
- Read
e2e/AGENTS.mdfirst. - Read only the files directly involved in the task:
- target
.featurefiles undere2e/features/ - related step files under
e2e/features/step-definitions/ e2e/features/support/hooks.tsande2e/features/support/world.tswhen session lifecycle or shared state matterse2e/scripts/run-cucumber.tsande2e/cucumber.config.tswhen tags or execution flow matter
- target
- Read
references/playwright-best-practices.mdonly when locator, assertion, isolation, or waiting choices are involved. - Read
references/cucumber-best-practices.mdonly when scenario wording, step granularity, tags, or expression design are involved. - Re-check official Playwright or Cucumber docs with the available documentation tools before introducing a new framework pattern.
Keep this skill focused on Cucumber, Playwright, and package-level E2E guidance. Put feature-specific conventions in the owning feature's AGENTS.md instead of adding them here.
Local Rules
e2e/uses Cucumber for scenarios and Playwright as the browser layer.DifyWorldis the per-scenario context object. TypethisasDifyWorldand useasync function, not arrow functions.- Keep glue organized by capability under
e2e/features/step-definitions/; usecommon/only for broadly reusable steps. - Browser session behavior comes from
features/support/hooks.ts:- default: authenticated session with shared storage state
@unauthenticated: clean browser context@authenticated: readability/selective-run tag only unless implementation changes@fresh: only fore2e:full*flows
- Do not import Playwright Test runner patterns that bypass the current Cucumber +
DifyWorldarchitecture unless the task is explicitly about changing that architecture.
Workflow
- Rebuild local context.
- Inspect the target feature area.
- Reuse an existing step when wording and behavior already match.
- Add a new step only for a genuinely new user action or assertion.
- Before adding several similar steps, scan the target capability for an existing domain noun that can be parameterized without hiding behavior.
- Keep edits close to the current capability folder unless the step is broadly reusable.
- Write behavior-first scenarios.
- Describe user-observable behavior, not DOM mechanics.
- Keep each scenario focused on one workflow or outcome.
- Keep scenarios independent and re-runnable.
- Write step definitions in the local style.
- Keep one step to one user-visible action or one assertion.
- Prefer Cucumber Expressions such as
{string}and{int}. - Use a bounded regex only when the accepted values are a small explicit domain set and Cucumber Expressions would make the Gherkin less natural.
- Do not create one-off steps for each case variant when the same domain action or outcome applies to named surfaces, modes, or resources.
- Scope locators to stable containers when the page has repeated elements.
- Avoid page-object layers or extra helper abstractions unless repeated complexity clearly justifies them.
- Use Playwright in the local style.
- Prefer user-facing locators:
getByRole,getByLabel,getByPlaceholder,getByText, thengetByTestIdfor explicit contracts. - Use web-first
expect(...)assertions. - Do not use
waitForTimeout, manual polling, or raw visibility checks when a locator action or retrying assertion already expresses the behavior. - Use
expect.pollfor API persistence, backend eventual consistency, captured browser events, or other non-DOM state; prefer locator assertions for DOM readiness and visible UI state. - If a product element has real user-facing semantics but no accessible name, prefer fixing that accessible contract over adding a test id.
- Prefer user-facing locators:
- Validate narrowly.
- Run the narrowest tagged scenario or flow that exercises the change.
- Run
vpr lint --fix --quietfrom the repository root andpnpm -C e2e type-check. - Broaden verification only when the change affects hooks, tags, setup, or shared step semantics.
Review Checklist
- Does the scenario describe behavior rather than implementation?
- Does it fit the current session model, tags, and
DifyWorldusage? - Should an existing step be reused instead of adding a new one?
- Are locators user-facing and assertions web-first?
- Does the change introduce hidden coupling across scenarios, tags, or instance state?
- Does it document or implement behavior that differs from the real hooks or configuration?
Lead findings with correctness, flake risk, and architecture drift.
