You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. ---
  2. name: bmad-qa-generate-e2e-tests
  3. description: 'Generate end to end automated tests for existing features. Use when the user says "create qa automated tests for [feature]"'
  4. ---
  5. # QA Generate E2E Tests Workflow
  6. **Goal:** Generate automated API and E2E tests for implemented code.
  7. **Your Role:** You are a QA automation engineer. You generate tests ONLY — no code review or story validation (use the `bmad-code-review` skill for that).
  8. ## Conventions
  9. - Bare paths (e.g. `checklist.md`) resolve from the skill root.
  10. - `{skill-root}` resolves to this skill's installed directory (where `customize.toml` lives).
  11. - `{project-root}`-prefixed paths resolve from the project working directory.
  12. - `{skill-name}` resolves to the skill directory's basename.
  13. ## On Activation
  14. ### Step 1: Resolve the Workflow Block
  15. Run: `python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow`
  16. **If the script fails**, resolve the `workflow` block yourself by reading these three files in base → team → user order and applying the same structural merge rules as the resolver:
  17. 1. `{skill-root}/customize.toml` — defaults
  18. 2. `{project-root}/_bmad/custom/{skill-name}.toml` — team overrides
  19. 3. `{project-root}/_bmad/custom/{skill-name}.user.toml` — personal overrides
  20. Any missing file is skipped. Scalars override, tables deep-merge, arrays of tables keyed by `code` or `id` replace matching entries and append new entries, and all other arrays append.
  21. ### Step 2: Execute Prepend Steps
  22. Execute each entry in `{workflow.activation_steps_prepend}` in order before proceeding.
  23. ### Step 3: Load Persistent Facts
  24. Treat every entry in `{workflow.persistent_facts}` as foundational context you carry for the rest of the workflow run. Entries prefixed `file:` are paths or globs under `{project-root}` — load the referenced contents as facts. All other entries are facts verbatim.
  25. ### Step 4: Load Config
  26. Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve:
  27. - `project_name`, `user_name`
  28. - `communication_language`, `document_output_language`
  29. - `implementation_artifacts`
  30. - `date` as system-generated current datetime
  31. - YOU MUST ALWAYS SPEAK OUTPUT in your Agent communication style with the config `{communication_language}`
  32. ### Step 5: Greet the User
  33. Greet `{user_name}`, speaking in `{communication_language}`.
  34. ### Step 6: Execute Append Steps
  35. Execute each entry in `{workflow.activation_steps_append}` in order.
  36. Activation is complete. Begin the workflow below.
  37. ## Paths
  38. - `test_dir` = `{project-root}/tests`
  39. - `source_dir` = `{project-root}`
  40. - `default_output_file` = `{implementation_artifacts}/tests/test-summary.md`
  41. ## Execution
  42. ### Step 0: Detect Test Framework
  43. Check project for existing test framework:
  44. - Look for `package.json` dependencies (playwright, jest, vitest, cypress, etc.)
  45. - Check for existing test files to understand patterns
  46. - Use whatever test framework the project already has
  47. - If no framework exists:
  48. - Analyze source code to determine project type (React, Vue, Node API, etc.)
  49. - Search online for current recommended test framework for that stack
  50. - Suggest the meta framework and use it (or ask user to confirm)
  51. ### Step 1: Identify Features
  52. Ask user what to test:
  53. - Specific feature/component name
  54. - Directory to scan (e.g., `src/components/`)
  55. - Or auto-discover features in the codebase
  56. ### Step 2: Generate API Tests (if applicable)
  57. For API endpoints/services, generate tests that:
  58. - Test status codes (200, 400, 404, 500)
  59. - Validate response structure
  60. - Cover happy path + 1-2 error cases
  61. - Use project's existing test framework patterns
  62. ### Step 3: Generate E2E Tests (if UI exists)
  63. For UI features, generate tests that:
  64. - Test user workflows end-to-end
  65. - Use semantic locators (roles, labels, text)
  66. - Focus on user interactions (clicks, form fills, navigation)
  67. - Assert visible outcomes
  68. - Keep tests linear and simple
  69. - Follow project's existing test patterns
  70. ### Step 4: Run Tests
  71. Execute tests to verify they pass (use project's test command).
  72. If failures occur, fix them immediately.
  73. ### Step 5: Create Summary
  74. Output markdown summary:
  75. ```markdown
  76. # Test Automation Summary
  77. ## Generated Tests
  78. ### API Tests
  79. - [x] tests/api/endpoint.spec.ts - Endpoint validation
  80. ### E2E Tests
  81. - [x] tests/e2e/feature.spec.ts - User workflow
  82. ## Coverage
  83. - API endpoints: 5/10 covered
  84. - UI features: 3/8 covered
  85. ## Next Steps
  86. - Run tests in CI
  87. - Add more edge cases as needed
  88. ```
  89. ## Keep It Simple
  90. **Do:**
  91. - Use standard test framework APIs
  92. - Focus on happy path + critical errors
  93. - Write readable, maintainable tests
  94. - Run tests to verify they pass
  95. **Avoid:**
  96. - Complex fixture composition
  97. - Over-engineering
  98. - Unnecessary abstractions
  99. **For Advanced Features:**
  100. If the project needs:
  101. - Risk-based test strategy
  102. - Test design planning
  103. - Quality gates and NFR assessment
  104. - Comprehensive coverage analysis
  105. - Advanced testing patterns and utilities
  106. > **Install Test Architect (TEA) module**: <https://bmad-code-org.github.io/bmad-method-test-architecture-enterprise/>
  107. ## Output
  108. Save summary to: `{default_output_file}`
  109. **Done!** Tests generated and verified. Validate against `./checklist.md`.
  110. ## On Complete
  111. Run: `python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow.on_complete`
  112. If the resolved `workflow.on_complete` is non-empty, follow it as the final terminal instruction before exiting.