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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. # Test Framework Setup - Validation Checklist
  2. This checklist ensures the framework workflow completes successfully and all deliverables meet quality standards.
  3. ---
  4. ## Prerequisites
  5. Before starting the workflow:
  6. - [ ] Project root contains a valid project manifest (`package.json`, `pyproject.toml`, `pom.xml`, `build.gradle`, `go.mod`, `*.csproj`, `Gemfile`, or `Cargo.toml`)
  7. - [ ] No existing test framework detected that conflicts with the target setup
  8. - [ ] Project type identifiable (React, Vue, Angular, Next.js, Node, Python, Java, Go, .NET, Ruby, Rust, etc.)
  9. - [ ] Bundler identifiable (Vite, Webpack, Rollup, esbuild) or not applicable (backend projects)
  10. - [ ] User has write permissions to create directories and files
  11. ---
  12. ## Process Steps
  13. ### Step 1: Preflight Checks
  14. - [ ] Stack type detected (`frontend`, `backend`, or `fullstack`)
  15. - [ ] Project manifest successfully read and parsed (`package.json`, `pyproject.toml`, `pom.xml`, `go.mod`, etc.)
  16. - [ ] Project type extracted correctly
  17. - [ ] Bundler identified (or marked as N/A for backend projects)
  18. - [ ] No framework conflicts detected
  19. - [ ] Architecture documents located (if available)
  20. ### Step 2: Framework Selection
  21. - [ ] Framework auto-detection logic executed
  22. - [ ] Framework choice justified (Playwright vs Cypress for frontend; pytest/JUnit/Go test/xUnit/RSpec for backend)
  23. - [ ] Framework preference respected (if explicitly set via `config.test_framework`)
  24. - [ ] User notified of framework selection and rationale
  25. ### Step 3: Directory Structure
  26. - [ ] `tests/` root directory created
  27. - [ ] `tests/e2e/` directory created (or user's preferred structure)
  28. - [ ] `tests/support/` directory created (critical pattern)
  29. - [ ] `tests/support/fixtures/` directory created
  30. - [ ] `tests/support/fixtures/factories/` directory created
  31. - [ ] `tests/support/helpers/` directory created
  32. - [ ] `tests/support/page-objects/` directory created (if applicable)
  33. - [ ] All directories have correct permissions
  34. **Note**: Test organization is flexible (e2e/, api/, integration/). The **support/** folder is the key pattern.
  35. ### Step 4: Configuration Files
  36. - [ ] Framework config file created (`playwright.config.ts` or `cypress.config.ts`)
  37. - [ ] Config file uses TypeScript (if `use_typescript: true`)
  38. - [ ] Timeouts configured correctly (action: 15s, navigation: 30s, test: 60s)
  39. - [ ] Base URL configured with environment variable fallback
  40. - [ ] Trace set to `retain-on-failure-and-retries`, screenshot to `only-on-failure`, video to `retain-on-failure`
  41. - [ ] Multiple reporters configured (HTML + JUnit + console)
  42. - [ ] Parallel execution enabled
  43. - [ ] CI-specific settings configured (retries, workers)
  44. - [ ] Config file is syntactically valid (no compilation errors)
  45. ### Step 5: Environment Configuration
  46. - [ ] `.env.example` created in project root
  47. - [ ] `TEST_ENV` variable defined
  48. - [ ] `BASE_URL` variable defined with default
  49. - [ ] `API_URL` variable defined (if applicable)
  50. - [ ] Authentication variables defined (if applicable)
  51. - [ ] Feature flag variables defined (if applicable)
  52. - [ ] `.nvmrc` created with appropriate Node version
  53. ### Step 6: Fixture Architecture
  54. - [ ] `tests/support/fixtures/index.ts` created
  55. - [ ] Base fixture extended from Playwright/Cypress
  56. - [ ] Type definitions for fixtures created
  57. - [ ] mergeTests pattern implemented (if multiple fixtures)
  58. - [ ] Auto-cleanup logic included in fixtures
  59. - [ ] Fixture architecture follows knowledge base patterns
  60. ### Step 7: Data Factories
  61. - [ ] At least one factory created (e.g., UserFactory)
  62. - [ ] Factories use @faker-js/faker for realistic data
  63. - [ ] Factories track created entities (for cleanup)
  64. - [ ] Factories implement `cleanup()` method
  65. - [ ] Factories integrate with fixtures
  66. - [ ] Factories follow knowledge base patterns
  67. ### Step 8: Sample Tests
  68. - [ ] Example test file created (`tests/e2e/example.spec.ts`)
  69. - [ ] Test uses fixture architecture
  70. - [ ] Test demonstrates data factory usage
  71. - [ ] Test uses proper selector strategy (data-testid)
  72. - [ ] Test follows Given-When-Then structure
  73. - [ ] Test includes proper assertions
  74. - [ ] Network interception demonstrated (if applicable)
  75. ### Step 9: Helper Utilities
  76. - [ ] API helper created (if API testing needed)
  77. - [ ] Network helper created (if network mocking needed)
  78. - [ ] Auth helper created (if authentication needed)
  79. - [ ] Helpers follow functional patterns
  80. - [ ] Helpers have proper error handling
  81. ### Step 10: Documentation
  82. - [ ] `tests/README.md` created
  83. - [ ] Setup instructions included
  84. - [ ] Running tests section included
  85. - [ ] Architecture overview section included
  86. - [ ] Best practices section included
  87. - [ ] CI integration section included
  88. - [ ] Knowledge base references included
  89. - [ ] Troubleshooting section included
  90. ### Step 11: Build & Test Script Updates
  91. - [ ] Minimal test script added to appropriate config (`package.json` for frontend, `Makefile`/`pyproject.toml`/`build.gradle` for backend)
  92. - [ ] Test framework dependency added (if not already present)
  93. - [ ] Type definitions added (if TypeScript)
  94. - [ ] Users can extend with additional scripts as needed
  95. ---
  96. ## Output Validation
  97. ### Configuration Validation
  98. - [ ] Config file loads without errors
  99. - [ ] Config file passes linting (if linter configured)
  100. - [ ] Config file uses correct syntax for chosen framework
  101. - [ ] All paths in config resolve correctly
  102. - [ ] Reporter output directories exist or are created on test run
  103. ### Test Execution Validation
  104. - [ ] Sample test runs successfully
  105. - [ ] Test execution produces expected output (pass/fail)
  106. - [ ] Test artifacts generated correctly (traces, screenshots, videos)
  107. - [ ] Test report generated successfully
  108. - [ ] No console errors or warnings during test run
  109. ### Directory Structure Validation
  110. - [ ] All required directories exist
  111. - [ ] Directory structure matches framework conventions
  112. - [ ] No duplicate or conflicting directories
  113. - [ ] Directories accessible with correct permissions
  114. ### File Integrity Validation
  115. - [ ] All generated files are syntactically correct
  116. - [ ] No placeholder text left in files (e.g., "TODO", "FIXME")
  117. - [ ] All imports resolve correctly
  118. - [ ] No hardcoded credentials or secrets in files
  119. - [ ] All file paths use correct separators for OS
  120. ---
  121. ## Quality Checks
  122. ### Code Quality
  123. - [ ] Generated code follows project coding standards
  124. - [ ] TypeScript types are complete and accurate (no `any` unless necessary)
  125. - [ ] No unused imports or variables
  126. - [ ] Consistent code formatting (matches project style)
  127. - [ ] No linting errors in generated files
  128. ### Best Practices Compliance
  129. - [ ] Fixture architecture follows pure function → fixture → mergeTests pattern
  130. - [ ] Data factories implement auto-cleanup
  131. - [ ] Network interception occurs before navigation
  132. - [ ] Selectors use data-testid strategy
  133. - [ ] Artifacts only captured on failure
  134. - [ ] Tests follow Given-When-Then structure
  135. - [ ] No hard-coded waits or sleeps
  136. ### Knowledge Base Alignment
  137. - [ ] Fixture pattern matches `fixture-architecture.md`
  138. - [ ] Data factories match `data-factories.md`
  139. - [ ] Network handling matches `network-first.md`
  140. - [ ] Config follows `playwright-config.md` or `test-config.md`
  141. - [ ] Test quality matches `test-quality.md`
  142. ### Pact Consumer CDC Alignment (when `tea_use_pactjs_utils` enabled)
  143. - [ ] `vitest.config.pact.ts` is minimal (no pool/coverage/setup copied from unit config)
  144. - [ ] Script names match pactjs-utils (`test:pact:consumer`, `publish:pact`, `can:i:deploy:consumer`, `record:consumer:deployment`)
  145. - [ ] Scripts source `env-setup.sh` inline in package.json
  146. - [ ] Shell scripts use `pact-broker` not `npx pact-broker`
  147. - [ ] Shell scripts use `PACTICIPANT` env var pattern (not hardcoded service names)
  148. - [ ] `can-i-deploy.sh` has `--retry-while-unknown=10 --retry-interval=30`
  149. - [ ] `record-deployment.sh` has branch guard (only records on main/master)
  150. - [ ] `env-setup.sh` uses `set -eu`; broker scripts use `set -euo pipefail` — each with explanatory comment
  151. - [ ] CI workflow named `contract-test-consumer.yml`
  152. - [ ] CI has workflow-level env block (not per-step)
  153. - [ ] CI has `detect-breaking-change` step before install
  154. - [ ] CI step numbering skips (3) — webhook-triggered provider verification
  155. - [ ] CI can-i-deploy has `PACT_BREAKING_CHANGE != 'true'` condition
  156. - [ ] CI has NO upload-artifact step (broker is source of truth)
  157. - [ ] `.github/actions/detect-breaking-change/action.yml` exists
  158. - [ ] Consumer tests use `.pacttest.ts` extension
  159. - [ ] Consumer tests use PactV4 `addInteraction()` builder (not PactV3 fluent API)
  160. - [ ] Consumer tests call REAL consumer code (actual API client functions), NOT raw `fetch()`
  161. - [ ] Consumer code exposes URL injection mechanism (`setApiUrl()`, env var, or constructor param)
  162. - [ ] Local consumer-helpers shim present if `@seontechnologies/pactjs-utils` not installed
  163. - [ ] `.gitignore` includes `/pacts/` and `pact-logs/`
  164. ### Security Checks
  165. - [ ] No credentials in configuration files
  166. - [ ] .env.example contains placeholders, not real values
  167. - [ ] Sensitive test data handled securely
  168. - [ ] API keys and tokens use environment variables
  169. - [ ] No secrets committed to version control
  170. ---
  171. ## Integration Points
  172. ### Status File Integration
  173. - [ ] Framework initialization logged in Quality & Testing Progress section
  174. - [ ] Status file updated with completion timestamp
  175. - [ ] Status file shows framework: Playwright or Cypress
  176. ### Knowledge Base Integration
  177. - [ ] Relevant knowledge fragments identified from tea-index.csv
  178. - [ ] Knowledge fragments successfully loaded
  179. - [ ] Patterns from knowledge base applied correctly
  180. - [ ] Knowledge base references included in documentation
  181. ### Workflow Dependencies
  182. - [ ] Can proceed to `ci` workflow after completion
  183. - [ ] Can proceed to `test-design` workflow after completion
  184. - [ ] Can proceed to `atdd` workflow after completion
  185. - [ ] Framework setup compatible with downstream workflows
  186. ---
  187. ## Completion Criteria
  188. **All of the following must be true:**
  189. - [ ] All prerequisite checks passed
  190. - [ ] All process steps completed without errors
  191. - [ ] All output validations passed
  192. - [ ] All quality checks passed
  193. - [ ] All integration points verified
  194. - [ ] Sample test executes successfully
  195. - [ ] User can run the appropriate test command without errors (`npm run test:e2e`, `pytest`, `go test ./...`, etc.)
  196. - [ ] Documentation is complete and accurate
  197. - [ ] No critical issues or blockers identified
  198. ---
  199. ## Post-Workflow Actions
  200. **User must complete:**
  201. 1. [ ] Copy `.env.example` to `.env`
  202. 2. [ ] Fill in environment-specific values in `.env`
  203. 3. [ ] Run `npm install` to install test dependencies
  204. 4. [ ] Run `npm run test:e2e` to verify setup
  205. 5. [ ] Review `tests/README.md` for project-specific guidance
  206. **Recommended next workflows:**
  207. 1. [ ] Run `ci` workflow to set up CI/CD pipeline
  208. 2. [ ] Run `test-design` workflow to plan test coverage
  209. 3. [ ] Run `atdd` workflow when ready to develop stories
  210. ---
  211. ## Rollback Procedure
  212. If workflow fails and needs to be rolled back:
  213. 1. [ ] Delete `tests/` directory
  214. 2. [ ] Remove test scripts from package.json
  215. 3. [ ] Delete `.env.example` (if created)
  216. 4. [ ] Delete `.nvmrc` (if created)
  217. 5. [ ] Delete framework config file
  218. 6. [ ] Remove test dependencies from package.json (if added)
  219. 7. [ ] Run `npm install` to clean up node_modules
  220. ---
  221. ## Notes
  222. ### Common Issues
  223. **Issue**: Config file has TypeScript errors
  224. - **Solution**: Ensure `@playwright/test` or `cypress` types are installed
  225. **Issue**: Sample test fails to run
  226. - **Solution**: Check BASE_URL in .env, ensure app is running
  227. **Issue**: Fixture cleanup not working
  228. - **Solution**: Verify cleanup() is called in fixture teardown
  229. **Issue**: Network interception not working
  230. - **Solution**: Ensure route setup occurs before page.goto()
  231. ### Framework-Specific Considerations
  232. **Playwright:**
  233. - Requires Node.js 18+
  234. - Browser binaries auto-installed on first run
  235. - Trace viewer requires running `npx playwright show-trace`
  236. **Cypress:**
  237. - Requires Node.js 18+
  238. - Cypress app opens on first run
  239. - Component testing requires additional setup
  240. ### Version Compatibility
  241. - [ ] Node.js version matches .nvmrc
  242. - [ ] Framework version compatible with Node.js version
  243. - [ ] TypeScript version compatible with framework
  244. - [ ] All peer dependencies satisfied
  245. ---
  246. **Checklist Complete**: Sign off when all items checked and validated.
  247. **Completed by:** {name}
  248. **Date:** {date}
  249. **Framework:** { Playwright / Cypress or something else}
  250. **Notes:** {notes}