$npx -y skills add One-Man-Company/Skills-ContextManager --skill webapp-testingWeb application testing principles. E2E, Playwright, deep audit strategies.
| 1 | # Web App Testing |
| 2 | |
| 3 | > Discover and test everything. Leave no route untested. |
| 4 | |
| 5 | ## 🔧 Runtime Scripts |
| 6 | |
| 7 | **Execute these for automated browser testing:** |
| 8 | |
| 9 | | Script | Purpose | Usage | |
| 10 | |--------|---------|-------| |
| 11 | | `scripts/playwright_runner.py` | Basic browser test | `python scripts/playwright_runner.py https://example.com` | |
| 12 | | | With screenshot | `python scripts/playwright_runner.py <url> --screenshot` | |
| 13 | | | Accessibility check | `python scripts/playwright_runner.py <url> --a11y` | |
| 14 | |
| 15 | **Requires:** `pip install playwright && playwright install chromium` |
| 16 | |
| 17 | --- |
| 18 | |
| 19 | ## 1. Deep Audit Approach |
| 20 | |
| 21 | ### Discovery First |
| 22 | |
| 23 | | Target | How to Find | |
| 24 | |--------|-------------| |
| 25 | | Routes | Scan app/, pages/, router files | |
| 26 | | API endpoints | Grep for HTTP methods | |
| 27 | | Components | Find component directories | |
| 28 | | Features | Read documentation | |
| 29 | |
| 30 | ### Systematic Testing |
| 31 | |
| 32 | 1. **Map** - List all routes/APIs |
| 33 | 2. **Scan** - Verify they respond |
| 34 | 3. **Test** - Cover critical paths |
| 35 | |
| 36 | --- |
| 37 | |
| 38 | ## 2. Testing Pyramid for Web |
| 39 | |
| 40 | ``` |
| 41 | /\ E2E (Few) |
| 42 | / \ Critical user flows |
| 43 | /----\ |
| 44 | / \ Integration (Some) |
| 45 | /--------\ API, data flow |
| 46 | / \ |
| 47 | /------------\ Component (Many) |
| 48 | Individual UI pieces |
| 49 | ``` |
| 50 | |
| 51 | --- |
| 52 | |
| 53 | ## 3. E2E Test Principles |
| 54 | |
| 55 | ### What to Test |
| 56 | |
| 57 | | Priority | Tests | |
| 58 | |----------|-------| |
| 59 | | 1 | Happy path user flows | |
| 60 | | 2 | Authentication flows | |
| 61 | | 3 | Critical business actions | |
| 62 | | 4 | Error handling | |
| 63 | |
| 64 | ### E2E Best Practices |
| 65 | |
| 66 | | Practice | Why | |
| 67 | |----------|-----| |
| 68 | | Use data-testid | Stable selectors | |
| 69 | | Wait for elements | Avoid flaky tests | |
| 70 | | Clean state | Independent tests | |
| 71 | | Avoid implementation details | Test user behavior | |
| 72 | |
| 73 | --- |
| 74 | |
| 75 | ## 4. Playwright Principles |
| 76 | |
| 77 | ### Core Concepts |
| 78 | |
| 79 | | Concept | Use | |
| 80 | |---------|-----| |
| 81 | | Page Object Model | Encapsulate page logic | |
| 82 | | Fixtures | Reusable test setup | |
| 83 | | Assertions | Built-in auto-wait | |
| 84 | | Trace Viewer | Debug failures | |
| 85 | |
| 86 | ### Configuration |
| 87 | |
| 88 | | Setting | Recommendation | |
| 89 | |---------|----------------| |
| 90 | | Retries | 2 on CI | |
| 91 | | Trace | on-first-retry | |
| 92 | | Screenshots | on-failure | |
| 93 | | Video | retain-on-failure | |
| 94 | |
| 95 | --- |
| 96 | |
| 97 | ## 5. Visual Testing |
| 98 | |
| 99 | ### When to Use |
| 100 | |
| 101 | | Scenario | Value | |
| 102 | |----------|-------| |
| 103 | | Design system | High | |
| 104 | | Marketing pages | High | |
| 105 | | Component library | Medium | |
| 106 | | Dynamic content | Lower | |
| 107 | |
| 108 | ### Strategy |
| 109 | |
| 110 | - Baseline screenshots |
| 111 | - Compare on changes |
| 112 | - Review visual diffs |
| 113 | - Update intentional changes |
| 114 | |
| 115 | --- |
| 116 | |
| 117 | ## 6. API Testing Principles |
| 118 | |
| 119 | ### Coverage Areas |
| 120 | |
| 121 | | Area | Tests | |
| 122 | |------|-------| |
| 123 | | Status codes | 200, 400, 404, 500 | |
| 124 | | Response shape | Matches schema | |
| 125 | | Error messages | User-friendly | |
| 126 | | Edge cases | Empty, large, special chars | |
| 127 | |
| 128 | --- |
| 129 | |
| 130 | ## 7. Test Organization |
| 131 | |
| 132 | ### File Structure |
| 133 | |
| 134 | ``` |
| 135 | tests/ |
| 136 | ├── e2e/ # Full user flows |
| 137 | ├── integration/ # API, data |
| 138 | ├── component/ # UI units |
| 139 | └── fixtures/ # Shared data |
| 140 | ``` |
| 141 | |
| 142 | ### Naming Convention |
| 143 | |
| 144 | | Pattern | Example | |
| 145 | |---------|---------| |
| 146 | | Feature-based | `login.spec.ts` | |
| 147 | | Descriptive | `user-can-checkout.spec.ts` | |
| 148 | |
| 149 | --- |
| 150 | |
| 151 | ## 8. CI Integration |
| 152 | |
| 153 | ### Pipeline Steps |
| 154 | |
| 155 | 1. Install dependencies |
| 156 | 2. Install browsers |
| 157 | 3. Run tests |
| 158 | 4. Upload artifacts (traces, screenshots) |
| 159 | |
| 160 | ### Parallelization |
| 161 | |
| 162 | | Strategy | Use | |
| 163 | |----------|-----| |
| 164 | | Per file | Playwright default | |
| 165 | | Sharding | Large suites | |
| 166 | | Workers | Multiple browsers | |
| 167 | |
| 168 | --- |
| 169 | |
| 170 | ## 9. Anti-Patterns |
| 171 | |
| 172 | | ❌ Don't | ✅ Do | |
| 173 | |----------|-------| |
| 174 | | Test implementation | Test behavior | |
| 175 | | Hardcode waits | Use auto-wait | |
| 176 | | Skip cleanup | Isolate tests | |
| 177 | | Ignore flaky tests | Fix root cause | |
| 178 | |
| 179 | --- |
| 180 | |
| 181 | > **Remember:** E2E tests are expensive. Use them for critical paths only. |