@xenos1996/usa 2.4.0 → 2.5.0

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.
@@ -0,0 +1,240 @@
1
+ id: core/testing-assurance
2
+ title: Testing Assurance Markers
3
+ section: S7
4
+ section_title: Testing & Quality Assurance
5
+ description: >
6
+ Deterministic presence-markers for the testing assurance program: unit,
7
+ integration, and system layouts; contract tests; coverage and mutation
8
+ evidence; retry/determinism guards; failure assertions; and test-data
9
+ isolation. Every rule asserts only that a marker exists — never that the
10
+ tests are good, sufficient, or green.
11
+ version: '1.0'
12
+
13
+ rules:
14
+ - id: TAS-001
15
+ title: A unit-test layout exists
16
+ section: S7
17
+ section_title: Testing & Quality Assurance
18
+ severity: MEDIUM
19
+ class: correctness
20
+ check:
21
+ kind: any_file
22
+ patterns:
23
+ - 'tests/unit/**'
24
+ - 'test/unit/**'
25
+ - 'unit/**'
26
+ - '**/*.unit.test.*'
27
+ - '**/*.unit.spec.*'
28
+ why: 'A conventional unit-test location tells contributors and CI exactly where confidence lives.'
29
+ remediation: 'Put unit tests under tests/unit (or mark them *.unit.test.*) and wire the directory into CI.'
30
+ references: ['Testing-Trophy', 'OpenSSF-Scorecard:CI-Tests']
31
+
32
+ - id: TAS-002
33
+ title: An integration-test layout exists
34
+ section: S7
35
+ section_title: Testing & Quality Assurance
36
+ severity: MEDIUM
37
+ class: correctness
38
+ check:
39
+ kind: any_file
40
+ patterns:
41
+ - 'tests/integration/**'
42
+ - 'test/integration/**'
43
+ - 'tests/integ/**'
44
+ - '**/*.integration.test.*'
45
+ - '**/*.integ.test.*'
46
+ - '**/*.int.test.*'
47
+ why: 'Unit tests with everything mocked verify the mock, not the seam; a named integration layout is where seam coverage lives.'
48
+ remediation: 'Add tests/integration with tests that exercise a real database, queue, or HTTP boundary.'
49
+ references: ['Testing-Trophy']
50
+
51
+ - id: TAS-003
52
+ title: A system/end-to-end test layout exists
53
+ section: S7
54
+ section_title: Testing & Quality Assurance
55
+ severity: MEDIUM
56
+ class: correctness
57
+ check:
58
+ kind: any_file
59
+ patterns:
60
+ - 'tests/e2e/**'
61
+ - 'test/e2e/**'
62
+ - 'e2e/**'
63
+ - 'tests/system/**'
64
+ - 'test/system/**'
65
+ - 'system-tests/**'
66
+ - '**/*.e2e.*'
67
+ why: 'Unit tests cannot tell you that checkout is broken because a button moved; a system-level layout is where journey coverage lives.'
68
+ remediation: 'Cover three journeys first: sign up/log in, the core money path, and the path that would lose data if it failed.'
69
+ references: ['Testing-Trophy']
70
+
71
+ - id: TAS-004
72
+ title: Contract tests are present
73
+ section: S7
74
+ section_title: Testing & Quality Assurance
75
+ severity: LOW
76
+ class: correctness
77
+ check:
78
+ kind: any_file
79
+ patterns:
80
+ - 'pacts/**'
81
+ - 'pact/**'
82
+ - '**/*.pact.*'
83
+ - 'tests/contracts/**'
84
+ - 'tests/contract/**'
85
+ - 'test/contracts/**'
86
+ - '**/*.contract.test.*'
87
+ - '**/*.contract.spec.*'
88
+ why: 'An API without checked-in consumer contracts can only be tested by hand; pact files and contract suites are the machine-checkable shadow of that agreement.'
89
+ remediation: 'Record consumer-driven contracts (e.g. Pact) or add a tests/contracts suite asserting request/response shapes.'
90
+ references: ['OpenAPI', 'Testing-Trophy']
91
+
92
+ - id: TAS-005
93
+ title: Coverage configuration or output is present
94
+ section: S7
95
+ section_title: Testing & Quality Assurance
96
+ severity: LOW
97
+ class: correctness
98
+ check:
99
+ kind: any_file
100
+ patterns:
101
+ - '.codecov.yml'
102
+ - 'codecov.yml'
103
+ - 'codecov.yaml'
104
+ - '.coveragerc'
105
+ - '.nycrc'
106
+ - '.nycrc.json'
107
+ - '.c8rc'
108
+ - '.c8rc.json'
109
+ - 'coverage/**'
110
+ - '**/lcov.info'
111
+ why: 'Unmeasured coverage drifts down silently; a coverage config or report artifact proves measurement was set up at least once.'
112
+ remediation: 'Turn on coverage reporting in the test runner and publish the number on every PR.'
113
+ references: ['NIST-SSDF-RV.1.1']
114
+
115
+ - id: TAS-006
116
+ title: A coverage threshold is pinned in the package.json-embedded jest config
117
+ section: S7
118
+ section_title: Testing & Quality Assurance
119
+ severity: LOW
120
+ class: correctness
121
+ check:
122
+ kind: json_path
123
+ file: 'package.json'
124
+ path: 'jest.coverageThreshold'
125
+ why: 'A gate stops the slide — but this check reads only the package.json-embedded jest config, the one JSON location with a stable schema. Thresholds kept in vitest.config, jest.config.js, or .nycrc are invisible to it.'
126
+ remediation: 'Set jest.coverageThreshold in package.json, or keep the threshold wherever the runner reads it and accept this marker as not-applicable.'
127
+ references: ['NIST-SSDF-RV.1.1']
128
+
129
+ - id: TAS-007
130
+ title: Mutation-testing evidence is present
131
+ section: S7
132
+ section_title: Testing & Quality Assurance
133
+ severity: FUTURE
134
+ class: correctness
135
+ check:
136
+ kind: any_file
137
+ patterns:
138
+ - 'reports/**/*mut*'
139
+ - 'reports/mutation/**'
140
+ - 'stryker.conf.*'
141
+ - '.stryker.conf.*'
142
+ - '.mutmut*'
143
+ - 'mutants/**'
144
+ why: 'Coverage tells you which lines ran, not whether the test would have failed if the line were wrong; a mutation config or report proves the question was asked.'
145
+ remediation: 'Run mutation testing on the highest-risk module first and keep the config or report in the repo.'
146
+ references: ['Mutation-Testing']
147
+
148
+ - id: TAS-008
149
+ title: A determinism guard is set in test config or CI
150
+ section: S7
151
+ section_title: Testing & Quality Assurance
152
+ severity: LOW
153
+ class: correctness
154
+ check:
155
+ kind: grep_present
156
+ pattern: '(forbidOnly|forbid-only|forbid_only|failOnConsole|fail-on-console)'
157
+ include:
158
+ [
159
+ 'playwright.config.*',
160
+ 'cypress.config.*',
161
+ 'vitest.config.*',
162
+ 'vitest.workspace.*',
163
+ 'jest.config.*',
164
+ 'package.json',
165
+ '.github/workflows/*.yml',
166
+ '.github/workflows/*.yaml',
167
+ '.gitlab-ci.yml',
168
+ ]
169
+ why: 'Focused-test markers (.only) committed by accident silently skip the rest of the suite; a forbid-only guard string proves the leak was thought about.'
170
+ remediation: 'Set forbidOnly on CI (e.g. Playwright forbidOnly) so a stray .only fails the build instead of shrinking it.'
171
+ references: ['Google-Testing-Blog:Flaky']
172
+
173
+ - id: TAS-009
174
+ title: A test retry budget is declared
175
+ section: S7
176
+ section_title: Testing & Quality Assurance
177
+ severity: LOW
178
+ class: operations
179
+ check:
180
+ kind: grep_present
181
+ pattern: '(retries\s*:\s*[1-9]|"retries"\s*:\s*[1-9]|retries=[1-9]|--retries[ =][1-9]|rerun-failed|flaky-test-retry|retry-on-failure)'
182
+ include:
183
+ [
184
+ 'playwright.config.*',
185
+ 'cypress.config.*',
186
+ 'vitest.config.*',
187
+ 'jest.config.*',
188
+ 'package.json',
189
+ '.github/workflows/*.yml',
190
+ '.github/workflows/*.yaml',
191
+ '.gitlab-ci.yml',
192
+ ]
193
+ why: 'A retries setting proves the project pays for reruns; it proves nothing about whether the tests are flaky or stable — only that the budget exists.'
194
+ remediation: 'Declare an explicit retry budget (e.g. retries: 2 on CI) and track which tests consume it; quarantine chronic consumers.'
195
+ references: ['Google-Testing-Blog:Flaky']
196
+
197
+ - id: TAS-010
198
+ title: Tests assert failure paths
199
+ section: S7
200
+ section_title: Testing & Quality Assurance
201
+ severity: MEDIUM
202
+ class: correctness
203
+ check:
204
+ kind: grep_present
205
+ pattern: '(\.toThrow\(|\.rejects|pytest\.raises|assertRaises|assert\.rejects|ShouldThrow|assert\.throws)'
206
+ include:
207
+ [
208
+ '**/*.test.*',
209
+ '**/*.spec.*',
210
+ '**/test_*.py',
211
+ '**/*_test.*',
212
+ 'tests/**',
213
+ 'test/**',
214
+ '__tests__/**',
215
+ 'spec/**',
216
+ ]
217
+ why: 'A suite that only asserts happy paths never proves the error handling works; failure-assertion strings prove at least one test looks at the sad path.'
218
+ remediation: 'Add negative tests for every permission boundary and every error branch — 401/403 paths, validation rejections, and cross-tenant attempts.'
219
+ references: ['Testing-Patterns']
220
+
221
+ - id: TAS-011
222
+ title: Test-data and environment isolation markers exist
223
+ section: S7
224
+ section_title: Testing & Quality Assurance
225
+ severity: LOW
226
+ class: maintainability
227
+ check:
228
+ kind: any_file
229
+ patterns:
230
+ - 'tests/fixtures/**'
231
+ - 'test/fixtures/**'
232
+ - '**/__fixtures__/**'
233
+ - '**/factories/**'
234
+ - '**/__factories__/**'
235
+ - '.env.test'
236
+ - '.env.testing'
237
+ - 'tests/.env.test'
238
+ why: 'Hand-built object literals in 200 tests make every schema change a 200-file migration, and tests sharing the live environment leak state; fixtures, factories, and a dedicated test env file are the markers of isolation.'
239
+ remediation: 'Add a factory or fixtures directory and a .env.test so tests generate data and never touch the dev or prod environment.'
240
+ references: ['Testing-Patterns', '12-Factor:Config']
package/rules/index.yaml CHANGED
@@ -19,6 +19,7 @@ packs:
19
19
  - core/architecture.yaml
20
20
  - core/code-quality.yaml
21
21
  - core/testing.yaml
22
+ - core/testing-assurance.yaml
22
23
  - core/cicd.yaml
23
24
  - core/release.yaml
24
25
  - core/dependencies.yaml