Add E2E Test
Context-aware command that adds a new feature or suite to the E2E spec and generates corresponding tests. Automatically detects whether to add to an existing suite or create a new one.
Additional instructions from the user: "$ARGUMENTS". Ignore if empty.
Phase 1: Discover Context
- Find all
E2E_TESTS.mdfiles in the project. - Read them to understand existing suites and features.
- Find existing E2E test files and read them to understand patterns.
- Analyze the user's request (
$ARGUMENTS) to determine:- Is this a new suite or an addition to an existing suite?
- What category does this feature belong to? (core/edge/error/side-effect/idempotency)
- What preconditions are needed?
- What assertions should be verified?
Phase 2: Determine Scope
If adding to an existing suite:
- Identify the target suite from the user's description.
- Check for conflicts with existing features (no duplicate names).
- Draft the new feature entry in the spec format.
If creating a new suite:
- Analyze the relevant source code to understand:
- What the feature does
- What external dependencies it has
- What states and error conditions exist
- Draft a complete suite with these sections, using heading levels appropriate to their nesting depth (e.g., if the suite is an H2, then these sections are H3; if the suite is an H3, they are H4; and so on):
Preconditions(heading with bullet list)Features(heading) containing individual features as flat peer subheadings one level deeper (do NOT create intermediate category headings — categories are specified only via<!-- category: ... -->HTML comments), across multiple categories (at minimum: core + error)Postconditions(heading with bullet list)
- Determine which
E2E_TESTS.mdfile to add it to (or create a new one).
Phase 3: Update Spec
- Present the draft spec entry to the user for review.
- Ask the user if they want to adjust anything.
- Add the approved entry to the appropriate
E2E_TESTS.mdfile:- For existing suites: add under the
### Featuressection - For new suites: add as a new
##section and add a link to the new suite in the Index section at the top of the file
- For existing suites: add under the
Phase 4: Generate Tests
-
If adding to an existing suite:
- Read the existing test file
- Add new test cases for the new features (e.g.,
it()blocks in vitest/jest) - Follow the existing patterns in that file exactly
-
If creating a new suite:
- Create a new test file following the project's conventions
- Include autogenerated header/footer
- Implement all features from the spec
-
Run the tests to verify they pass.
-
Run the project's formatter on modified/created files.
-
Present a summary of changes made.