|
| 1 | +# Socket CLI Test Suite Failure Analysis |
| 2 | + |
| 3 | +## Executive Summary |
| 4 | + |
| 5 | +**Total Test Results:** |
| 6 | +- Test Files: 77 failed | 207 passed | 1 skipped (285 total) |
| 7 | +- Individual Tests: 207 failed | 2011 passed | 10 skipped (2228 total) |
| 8 | +- Snapshot Failures: 44 failed |
| 9 | +- Test Success Rate: 90% of tests passing |
| 10 | + |
| 11 | +**Note:** The discrepancy between 77 failed test files and 260 individual test failures occurs because multiple test cases within the same file can fail independently. The categorization below counts individual failing test cases, not test files. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Failure Categories |
| 16 | + |
| 17 | +### 1. Mock/Stub Issues (109 failures - 42%) |
| 18 | + |
| 19 | +**Primary Issue:** `sockSdk.deleteOrgRepo is not a function` (107 occurrences) |
| 20 | + |
| 21 | +**Root Cause:** The Socket SDK mock is missing the `deleteOrgRepo` method, causing repository deletion tests to fail. |
| 22 | + |
| 23 | +**Affected Areas:** |
| 24 | +- Repository deletion tests (most common) |
| 25 | +- Organization tests |
| 26 | +- Constants tests |
| 27 | + |
| 28 | +**Example Files:** |
| 29 | +``` |
| 30 | +src/commands/repository/fetch-delete-repo.test.mts |
| 31 | +src/constants.test.mts (multiple test cases) |
| 32 | +src/flags.test.mts (multiple test cases) |
| 33 | +``` |
| 34 | + |
| 35 | +**Resolution:** Need to add `deleteOrgRepo` method to the Socket SDK mock configuration. |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +### 2. Snapshot Mismatches (104 failures - 40%) |
| 40 | + |
| 41 | +**Root Cause:** Output format has changed since snapshots were last updated. |
| 42 | + |
| 43 | +**Common Patterns:** |
| 44 | +- Help text changes |
| 45 | +- CLI output formatting changes |
| 46 | +- Flag description updates |
| 47 | +- Command response format changes |
| 48 | + |
| 49 | +**Example Files:** |
| 50 | +``` |
| 51 | +src/commands/fix/cmd-fix.test.mts (multiple snapshots) |
| 52 | +src/commands/scan/cmd-scan-create.test.mts |
| 53 | +src/commands/cdxgen/cmd-cdxgen.test.mts |
| 54 | +src/commands/config/cmd-config-get.test.mts |
| 55 | +``` |
| 56 | + |
| 57 | +**Resolution:** Run `pnpm testu` to update all snapshots after verifying changes are intentional. |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +### 3. Import/Module Errors (31 failures - 12%) |
| 62 | + |
| 63 | +**Pattern A: Missing Source Files (25+ occurrences)** |
| 64 | + |
| 65 | +Files that were moved, renamed, or not built: |
| 66 | + |
| 67 | +``` |
| 68 | +Cannot find module '../../../src/utils/memoization.mts' |
| 69 | + - test/helpers/memoization.test.mts |
| 70 | + - test/utils/memoization.test.mts |
| 71 | +
|
| 72 | +Cannot find module '../../../src/utils/performance.mts' |
| 73 | + - test/helpers/performance.test.mts |
| 74 | + - test/utils/performance.test.mts |
| 75 | +
|
| 76 | +Cannot find module '../../../src/utils/test-fixtures.mts' |
| 77 | + - src/commands/optimize/cmd-optimize-pnpm-versions.test.mts |
| 78 | + - src/commands/optimize/cmd-optimize.test.mts |
| 79 | +
|
| 80 | +Cannot find module '../../../src/utils/cache-strategies.mts' |
| 81 | + - test/utils/cache-strategies.test.mts |
| 82 | +
|
| 83 | +Cannot find module '../../constants/cli.mts' |
| 84 | + - src/commands/cli.test.mts |
| 85 | +
|
| 86 | +Cannot find module '../config.mts' |
| 87 | + - src/utils/config.test.mts |
| 88 | +
|
| 89 | +Cannot find module '../home-cache-time.mts' |
| 90 | + - src/utils/home-cache-time.test.mts |
| 91 | +
|
| 92 | +Cannot find module '../sanitize-names.mts' |
| 93 | + - src/utils/sanitize-names.test.mts |
| 94 | +
|
| 95 | +Cannot find module './alerts-map.mts' |
| 96 | + - src/utils/pnpm/scanning.test.mts |
| 97 | + - src/utils/socket/alerts.test.mts |
| 98 | +
|
| 99 | +Cannot find module './handle-patch.mts' |
| 100 | + - src/commands/patch/handle-patch-apply.test.mts |
| 101 | +
|
| 102 | +Cannot find module './resolve.mts' |
| 103 | + - src/utils/fs/path-resolve.test.mts |
| 104 | +
|
| 105 | +Cannot find module './backup.mts' |
| 106 | + - src/utils/manifest/patch-backup.test.mts |
| 107 | +
|
| 108 | +Cannot find module './hash.mts' |
| 109 | + - src/utils/manifest/patch-hash.test.mts |
| 110 | +
|
| 111 | +Cannot find module './index.mts' |
| 112 | + - src/utils/manifest/patches.test.mts |
| 113 | +
|
| 114 | +And 10+ more similar issues... |
| 115 | +``` |
| 116 | + |
| 117 | +**Pattern B: Missing Registry Exports (2 occurrences)** |
| 118 | + |
| 119 | +``` |
| 120 | +Cannot find module '@socketsecurity/registry/tables' |
| 121 | + - test/helpers/output-formatting-tables.test.mts |
| 122 | + - test/utils/output-formatting-tables.test.mts |
| 123 | +``` |
| 124 | + |
| 125 | +**Resolution:** |
| 126 | +1. Run `pnpm build:dist:src` to ensure all source files are built |
| 127 | +2. Verify file paths and update imports to match current structure |
| 128 | +3. Check if registry exports exist in the expected location |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +### 4. Other/TypeErrors (16 failures - 6%) |
| 133 | + |
| 134 | +**Pattern A: Function Not Defined (2 occurrences)** |
| 135 | + |
| 136 | +``` |
| 137 | +TypeError: (0, getProcessEnv) is not a function |
| 138 | +``` |
| 139 | + |
| 140 | +**Pattern B: Undefined Property Access (14+ occurrences)** |
| 141 | + |
| 142 | +``` |
| 143 | +TypeError: Cannot read properties of undefined (reading 'endsWith') |
| 144 | +TypeError: Cannot read properties of undefined (reading 'builder') |
| 145 | +ReferenceError: fetchModulePath is not defined |
| 146 | +``` |
| 147 | + |
| 148 | +**Example Files:** |
| 149 | +``` |
| 150 | +src/commands/audit-log/output-audit-log.test.mts |
| 151 | +src/commands/organization/handle-dependencies.test.mts |
| 152 | +src/commands/organization/handle-organization-list.test.mts |
| 153 | +src/commands/organization/output-* (multiple files) |
| 154 | +src/commands/scan/output-* (multiple files) |
| 155 | +src/commands/repository/output-* (multiple files) |
| 156 | +``` |
| 157 | + |
| 158 | +**Resolution:** These require individual investigation to determine if: |
| 159 | +- Mock configuration is incomplete |
| 160 | +- Test setup is incorrect |
| 161 | +- Code changes broke test assumptions |
| 162 | + |
| 163 | +--- |
| 164 | + |
| 165 | +### 5. Timeout Issues (0 failures - 0%) |
| 166 | + |
| 167 | +**Status:** No tests are timing out. ✓ |
| 168 | + |
| 169 | +Some tests reference timeout-related flags (e.g., `--reach-analysis-timeout`) but these are passing or failing for other reasons (typically snapshot mismatches). |
| 170 | + |
| 171 | +--- |
| 172 | + |
| 173 | +### 6. Pure Logic/Assertion Failures (0 explicit failures) |
| 174 | + |
| 175 | +**Status:** All logic failures are captured in the categories above (primarily in snapshot and mock categories). ✓ |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | +## Priority Recommendations |
| 180 | + |
| 181 | +### High Priority (Quick Wins) |
| 182 | + |
| 183 | +1. **Add missing SDK mock method** (fixes 107 failures) |
| 184 | + - Add `deleteOrgRepo` to Socket SDK mock configuration |
| 185 | + - Estimated time: 5-10 minutes |
| 186 | + |
| 187 | +2. **Update snapshots** (fixes 104 failures) |
| 188 | + - Run `pnpm testu` after verifying output changes are correct |
| 189 | + - Estimated time: 5 minutes + review time |
| 190 | + |
| 191 | +### Medium Priority (Structural Fixes) |
| 192 | + |
| 193 | +3. **Fix import paths** (fixes 31 failures) |
| 194 | + - Build source files: `pnpm build:dist:src` |
| 195 | + - Update import paths to match current file structure |
| 196 | + - Verify registry exports exist |
| 197 | + - Estimated time: 30-60 minutes |
| 198 | + |
| 199 | +### Lower Priority (Individual Investigation) |
| 200 | + |
| 201 | +4. **Fix TypeErrors and undefined references** (fixes 16 failures) |
| 202 | + - Investigate each failing test individually |
| 203 | + - Update mocks and test setup as needed |
| 204 | + - Estimated time: 1-2 hours |
| 205 | + |
| 206 | +--- |
| 207 | + |
| 208 | +## Next Steps |
| 209 | + |
| 210 | +1. Run: `pnpm build:dist:src` (ensure source files are built) |
| 211 | +2. Fix SDK mock to include `deleteOrgRepo` method |
| 212 | +3. Run: `pnpm testu` (update all snapshots) |
| 213 | +4. Investigate remaining import path issues |
| 214 | +5. Address individual TypeErrors on a case-by-case basis |
| 215 | + |
| 216 | +**Expected Outcome:** Following these steps should reduce failures from 77 failed test files to approximately 10-15 files requiring individual attention. |
0 commit comments