@boopkit/cap-testing 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boopkit/cap-testing",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Jest testing setup and testing skills for AI agents",
5
5
  "files": [
6
6
  "scaffold/",
@@ -1,9 +1,9 @@
1
1
  # Light TDD Flow
2
- When you need to build features or implement changes, follow the Light TDD Flow:
2
+ When you need to build features, implement changes, or fix bugs, follow the Light TDD Flow. This includes bug fixes found during UAT — write the failing test *before* applying the fix.
3
3
 
4
4
  Red → Green → Refactor. Document "before" and "after" states.
5
5
 
6
- 1. **Red**: Run/write tests that expose the gap (failing test for new feature, reproduced bug, baseline metric). Verify that issues is *observed* and that tests fail for the expected reason. Document the "before" state.
6
+ 1. **Red**: Run/write tests that expose the gap (failing test for new feature, reproduced bug, baseline metric). Verify that the issue is *observed* and that tests fail for the expected reason. Document the "before" state. **For bug fixes**: write a test that reproduces the exact failure, then confirm it fails for the right reason before touching the implementation.
7
7
  2. **Green**: Implement the minimum change. Add any additional tests.
8
8
  3. **Verify**: Re-run all tests from steps 1-2. Type-checking alone is **not sufficient** — functional tests must pass. Check for regressions in related functionality. Verify from the user's perspective — don't just test internal state. For example, if the feature writes files the user interacts with, verify those files exist and are correct.
9
9
 
@@ -48,6 +48,8 @@ When the shared boundary is the filesystem or an in-memory data structure (CLI t
48
48
 
49
49
  ### Mock boundaries
50
50
 
51
+ Mocks are helpful for isolating orchestration logic, but their limitations must be recognized: a mock silently accepts anything, so it cannot catch failures that occur at real system boundaries. When you use a mock, acknowledge what it *doesn't* cover and ensure integration tests fill the gap.
52
+
51
53
  | Mock this | Don't mock this |
52
54
  |---|---|
53
55
  | Third-party HTTP (email, OAuth) | Adjacent services you own (use real `getServices()`) |
@@ -64,6 +66,39 @@ When code is backed by a config table (patterns, routes, flags, enums):
64
66
 
65
67
  ---
66
68
 
69
+ ## Bug found during UAT
70
+
71
+ When a bug is discovered through manual testing or UAT, follow this checklist:
72
+
73
+ 1. **Reproduce** — confirm the failure and understand the root cause.
74
+ 2. **Find the test gap** — look for an existing test that *should* have caught it. If one exists, understand why it didn't (usually: it mocked the boundary where the failure lives).
75
+ 3. **Write a failing test first** — TDD applies to bug fixes, not just features. Write a test that reproduces the exact failure, confirm it fails for the right reason (Red), *then* apply the fix (Green). See [tdd-light.skill.md](test.tdd-light.skill.md).
76
+ 4. **Choose the right test level** — if the bug occurred at a system boundary (database, external API, serialization), the test must cross that boundary. A mock-based test cannot catch a boundary failure.
77
+
78
+ ---
79
+
80
+ ## Raw SQL and integration tests
81
+
82
+ Any service function that uses `$queryRaw` or `$executeRaw` **must have an integration test that runs against the real database**. Mock-based tests for raw SQL provide false confidence — the mock accepts any query shape, but the real database may reject it (wrong column types, deserialization failures, missing columns).
83
+
84
+ **Pattern**: insert fixture data via raw SQL or Prisma, call the function under test, assert the result, clean up in `afterAll`.
85
+
86
+ **Especially important for `Unsupported` columns**: Prisma columns marked `Unsupported(...)` (e.g., pgvector `vector(1536)`) will cause runtime deserialization errors if selected in `$queryRaw`. TypeScript won't catch this, and mocks won't catch this. Only a real DB query will.
87
+
88
+ ---
89
+
90
+ ## Schema contract testing
91
+
92
+ When code produces a schema or structure that is validated by an external system, test the schema against that system's documented rules — don't assume your code is the arbiter of truth.
93
+
94
+ **Pattern**: write a test that walks the schema and asserts every invariant the consuming system requires. No mocks, no API calls — just structural validation.
95
+
96
+ **Example**: OpenAI structured outputs with `strict: true` require `additionalProperties: false` on every object node. A test walks the schema tree and asserts the property exists on each object. This catches schema authoring mistakes before they reach the API.
97
+
98
+ **When to apply**: any time your code produces configuration, schemas, or structured data that an external system validates — OpenAI schemas, JSON Schema for APIs, database DDL consumed by migration tools, etc.
99
+
100
+ ---
101
+
67
102
  ## Subsystem Testing Skills
68
103
 
69
104
  | Subsystem | Skill |