@facet-coverage/core 0.2.0 → 0.4.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.
- package/README.md +64 -523
- package/dist/cli/commands/analyze.d.ts.map +1 -1
- package/dist/cli/commands/analyze.js +2 -35
- package/dist/cli/commands/analyze.js.map +1 -1
- package/dist/cli/commands/generate.d.ts +5 -2
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +496 -16
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +2 -34
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/commands/watch.d.ts.map +1 -1
- package/dist/cli/commands/watch.js +2 -34
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/cli/index.js +6 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/config.d.ts +15 -0
- package/dist/cli/utils/config.d.ts.map +1 -0
- package/dist/cli/utils/config.js +88 -0
- package/dist/cli/utils/config.js.map +1 -0
- package/dist/core/FacetParser.d.ts +54 -2
- package/dist/core/FacetParser.d.ts.map +1 -1
- package/dist/core/FacetParser.js +151 -3
- package/dist/core/FacetParser.js.map +1 -1
- package/dist/core/IDChangeDetector.d.ts +50 -0
- package/dist/core/IDChangeDetector.d.ts.map +1 -0
- package/dist/core/IDChangeDetector.js +147 -0
- package/dist/core/IDChangeDetector.js.map +1 -0
- package/dist/core/TestScanner.d.ts +11 -0
- package/dist/core/TestScanner.d.ts.map +1 -1
- package/dist/core/TestScanner.js +76 -6
- package/dist/core/TestScanner.js.map +1 -1
- package/dist/core/Validator.d.ts +4 -0
- package/dist/core/Validator.d.ts.map +1 -1
- package/dist/core/Validator.js +22 -4
- package/dist/core/Validator.js.map +1 -1
- package/dist/types.d.ts +32 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Test every facet of your features**
|
|
6
6
|
|
|
7
|
-
*
|
|
7
|
+
*Write requirements naturally. Know what's tested. Track multi-stakeholder coverage automatically.*
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/@facet-coverage/core)
|
|
10
10
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -15,589 +15,132 @@
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
##
|
|
19
|
-
|
|
20
|
-
- [What is Facet?](#what-is-facet)
|
|
21
|
-
- [Installation](#installation)
|
|
22
|
-
- [Quick Start](#quick-start)
|
|
23
|
-
- [Linking Tests to Facets](#linking-tests-to-facets)
|
|
24
|
-
- [Project Structure](#project-structure)
|
|
25
|
-
- [CLI Commands](#cli-commands)
|
|
26
|
-
- [Playwright Integration](#playwright-integration)
|
|
27
|
-
- [Configuration](#configuration)
|
|
28
|
-
- [ID Patterns](#id-patterns)
|
|
29
|
-
- [Programmatic API](#programmatic-api)
|
|
30
|
-
- [Benefits](#benefits)
|
|
31
|
-
- [How Facet Differs](#how-facet-differs)
|
|
32
|
-
- [Key Principles](#key-principles)
|
|
33
|
-
- [Contributing](#contributing)
|
|
34
|
-
- [License](#license)
|
|
18
|
+
## Why Facet?
|
|
35
19
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## What is Facet?
|
|
39
|
-
|
|
40
|
-
Facet is a modern testing framework that lets you document features from multiple stakeholder perspectives while maintaining exact traceability to your tests.
|
|
20
|
+
Traditional testing asks "what did developers test?" Facet asks "what do stakeholders need, and is it tested?"
|
|
41
21
|
|
|
42
|
-
|
|
22
|
+
Real products serve multiple stakeholders—product owners, compliance teams, UX designers, security architects—each with their own requirements. Facet lets every stakeholder write requirements in natural language, then tracks whether tests actually cover them.
|
|
43
23
|
|
|
44
|
-
|
|
45
|
-
|-------------|-------------|
|
|
46
|
-
| **Business requirements** | Product owner specifications |
|
|
47
|
-
| **Compliance mandates** | Regulatory requirements (PCI-DSS, GDPR, etc.) |
|
|
48
|
-
| **UX standards** | Design system and accessibility rules |
|
|
49
|
-
| **Technical specs** | Architecture and API contracts |
|
|
50
|
-
|
|
51
|
-
All connected to the same tests. All tracked for coverage.
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## Installation
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
bun add -d @facet-coverage/core
|
|
59
|
-
```
|
|
24
|
+
**One feature. Many facets. All tracked.**
|
|
60
25
|
|
|
61
26
|
---
|
|
62
27
|
|
|
63
28
|
## Quick Start
|
|
64
29
|
|
|
65
|
-
###
|
|
30
|
+
### Install
|
|
66
31
|
|
|
67
32
|
```bash
|
|
68
|
-
|
|
33
|
+
bun add -d @facet-coverage/core
|
|
69
34
|
```
|
|
70
35
|
|
|
71
|
-
|
|
36
|
+
### 1. Each stakeholder writes their requirements
|
|
72
37
|
|
|
73
|
-
**
|
|
38
|
+
**Business Team** — `facets/business.md`
|
|
74
39
|
```markdown
|
|
75
40
|
## Guest Purchase Flow
|
|
76
|
-
|
|
77
|
-
A user who isn't logged in should be able to buy products. They add
|
|
78
|
-
items to cart, click checkout, provide email and payment details,
|
|
79
|
-
and get an order confirmation.
|
|
80
|
-
|
|
81
|
-
### Edge Cases
|
|
82
|
-
- Empty cart at checkout
|
|
83
|
-
- Invalid email format
|
|
84
|
-
- Payment gateway timeout
|
|
41
|
+
Users should complete purchases without creating an account.
|
|
85
42
|
```
|
|
86
43
|
|
|
87
|
-
**
|
|
44
|
+
**Compliance Team** — `facets/compliance.md`
|
|
88
45
|
```markdown
|
|
89
|
-
## PCI-DSS Payment Requirements
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
1. **Encryption in transit** - TLS 1.2+ required
|
|
94
|
-
2. **No CVV storage** - Use payment gateway, never store CVV
|
|
95
|
-
3. **Card masking** - Display only last 4 digits
|
|
46
|
+
## PCI-DSS Payment Requirements {#pci-dss}
|
|
47
|
+
1. **Encryption in transit** {#tls} - TLS 1.2+ required
|
|
48
|
+
2. **No CVV storage** {#cvv} - Never store CVV
|
|
49
|
+
3. **Card masking** {#masking} - Show only last 4 digits
|
|
96
50
|
```
|
|
97
51
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
This creates two files in `features/checkout/.facet/`:
|
|
105
|
-
- `structure.json` - facet definitions
|
|
106
|
-
- `facets.ts` - TypeScript types for type-safe linking
|
|
107
|
-
|
|
108
|
-
**structure.json:**
|
|
109
|
-
|
|
110
|
-
```json
|
|
111
|
-
{
|
|
112
|
-
"feature": "checkout",
|
|
113
|
-
"facets": [
|
|
114
|
-
{
|
|
115
|
-
"id": "business:guest-purchase-flow",
|
|
116
|
-
"source": {
|
|
117
|
-
"file": "facets/business.md",
|
|
118
|
-
"section": "guest-purchase-flow"
|
|
119
|
-
},
|
|
120
|
-
"type": "business"
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
"id": "compliance:pci-dss-payment-requirements",
|
|
124
|
-
"source": {
|
|
125
|
-
"file": "facets/compliance.md",
|
|
126
|
-
"section": "pci-dss-payment-requirements"
|
|
127
|
-
},
|
|
128
|
-
"type": "compliance"
|
|
129
|
-
}
|
|
130
|
-
]
|
|
131
|
-
}
|
|
52
|
+
**UX Team** — `facets/ux.md`
|
|
53
|
+
```markdown
|
|
54
|
+
## Mobile Checkout Experience
|
|
55
|
+
Large touch targets (44px min), single column layout, inline validation.
|
|
132
56
|
```
|
|
133
57
|
|
|
134
|
-
###
|
|
135
|
-
|
|
136
|
-
Import the generated types and use `facet()` in your tests:
|
|
58
|
+
### 2. Tests link to requirements
|
|
137
59
|
|
|
138
60
|
```typescript
|
|
139
|
-
// features/checkout/tests/checkout.spec.ts
|
|
140
|
-
import { test, expect } from 'bun:test'; // or jest, vitest, mocha...
|
|
141
61
|
import { Facets, facet } from '../.facet/facets';
|
|
142
62
|
|
|
143
|
-
test('guest user completes purchase', () => {
|
|
144
|
-
//
|
|
63
|
+
test('guest user completes purchase on mobile', () => {
|
|
64
|
+
// This test proves requirements for 3 different stakeholders
|
|
145
65
|
facet(Facets.BUSINESS_GUEST_PURCHASE_FLOW);
|
|
146
|
-
facet(Facets.
|
|
147
|
-
|
|
148
|
-
// Your test code
|
|
149
|
-
const order = checkout(cart, 'user@example.com', '4242...');
|
|
150
|
-
expect(order.confirmed).toBe(true);
|
|
151
|
-
expect(order.maskedCard).toBe('•••• 4242'); // PCI-DSS compliance
|
|
152
|
-
});
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
The `facet()` function is type-safe - TypeScript will error if you use an invalid facet ID!
|
|
156
|
-
|
|
157
|
-
### 4. Run Coverage
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
bunx facet analyze
|
|
161
|
-
```
|
|
66
|
+
facet(Facets.COMPLIANCE_PCI_DSS);
|
|
67
|
+
facet(Facets.UX_MOBILE_CHECKOUT_EXPERIENCE);
|
|
162
68
|
|
|
163
|
-
|
|
164
|
-
```
|
|
165
|
-
Facet Coverage Report
|
|
166
|
-
|
|
167
|
-
Overall: 100%
|
|
168
|
-
|
|
169
|
-
By Type:
|
|
170
|
-
business: 100% (1/1)
|
|
171
|
-
compliance: 100% (1/1)
|
|
172
|
-
|
|
173
|
-
Reports generated:
|
|
174
|
-
.facet-coverage/coverage.json
|
|
175
|
-
.facet-coverage/coverage.html
|
|
176
|
-
.facet-coverage/coverage.md
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
## Project Structure
|
|
182
|
-
|
|
183
|
-
```
|
|
184
|
-
project/
|
|
185
|
-
├── features/
|
|
186
|
-
│ ├── checkout/
|
|
187
|
-
│ │ ├── facets/
|
|
188
|
-
│ │ │ ├── business.md # Product owner writes
|
|
189
|
-
│ │ │ ├── compliance.md # Compliance team writes
|
|
190
|
-
│ │ │ └── ux.md # UX designer writes
|
|
191
|
-
│ │ ├── .facet/
|
|
192
|
-
│ │ │ ├── structure.json # Generated facet definitions
|
|
193
|
-
│ │ │ └── facets.ts # Generated TypeScript types
|
|
194
|
-
│ │ └── tests/
|
|
195
|
-
│ │ └── checkout.spec.ts
|
|
196
|
-
│ │
|
|
197
|
-
│ └── authentication/
|
|
198
|
-
│ ├── facets/
|
|
199
|
-
│ ├── .facet/
|
|
200
|
-
│ └── tests/
|
|
201
|
-
│
|
|
202
|
-
├── .facet-coverage/ # Coverage reports
|
|
203
|
-
│ ├── coverage.json
|
|
204
|
-
│ ├── coverage.html
|
|
205
|
-
│ └── coverage.md
|
|
206
|
-
│
|
|
207
|
-
└── facet.config.js # Configuration
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
## Linking Tests to Facets
|
|
213
|
-
|
|
214
|
-
Use the `facet()` function inside your tests - just like `expect()` but for coverage tracking!
|
|
215
|
-
|
|
216
|
-
### Recommended: Type-Safe with `facet()` Function
|
|
69
|
+
const order = checkout(cart, 'user@example.com', '4242424242424242');
|
|
217
70
|
|
|
218
|
-
```typescript
|
|
219
|
-
import { test, expect } from 'bun:test'; // or jest, vitest, mocha...
|
|
220
|
-
import { Facets, facet } from '../.facet/facets';
|
|
221
|
-
|
|
222
|
-
test('guest user can complete a purchase', () => {
|
|
223
|
-
// Declare which facets this test covers - type-safe with autocomplete!
|
|
224
|
-
facet(Facets.BUSINESS_GUEST_PURCHASE_FLOW);
|
|
225
|
-
facet(Facets.COMPLIANCE_PCI_DSS_PAYMENT_REQUIREMENTS);
|
|
226
|
-
|
|
227
|
-
// Your test code
|
|
228
|
-
const order = checkout(cart, email, card);
|
|
229
71
|
expect(order.confirmed).toBe(true);
|
|
72
|
+
expect(order.maskedCard).toBe('•••• 4242'); // PCI-DSS compliance
|
|
230
73
|
});
|
|
231
74
|
|
|
232
|
-
test('
|
|
233
|
-
//
|
|
234
|
-
facet(Facets.
|
|
235
|
-
|
|
236
|
-
expect(payment.encrypted).toBe(true);
|
|
237
|
-
});
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
**Benefits:**
|
|
241
|
-
- Full TypeScript autocomplete
|
|
242
|
-
- Compile-time validation (invalid facet IDs cause errors)
|
|
243
|
-
- Clean, readable syntax
|
|
244
|
-
- Works with any testing framework
|
|
245
|
-
|
|
246
|
-
**Generated `facets.ts` includes:**
|
|
247
|
-
- `FacetId` - Union type of all valid facet IDs
|
|
248
|
-
- `Facets` - Object with constants for each facet
|
|
249
|
-
- `facet()` - Type-safe function to declare coverage
|
|
250
|
-
|
|
251
|
-
### Alternative: Comment Annotations
|
|
75
|
+
test('TLS encryption enforced', () => {
|
|
76
|
+
// Track specific compliance sub-requirements
|
|
77
|
+
facet(Facets.COMPLIANCE_PCI_DSS__TLS);
|
|
252
78
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
```typescript
|
|
256
|
-
// @facet business:guest-purchase-flow, compliance:pci-dss
|
|
257
|
-
test('guest user completes purchase', () => {
|
|
258
|
-
// Your test code
|
|
79
|
+
expect(paymentEndpoint.protocol).toBe('https');
|
|
259
80
|
});
|
|
260
81
|
```
|
|
261
82
|
|
|
262
|
-
###
|
|
263
|
-
|
|
264
|
-
| Method | Type-Safe | Syntax |
|
|
265
|
-
|--------|-----------|--------|
|
|
266
|
-
| `facet()` function | Yes | `facet(Facets.ID)` inside test body |
|
|
267
|
-
| Comment annotation | No | `// @facet id` above test |
|
|
268
|
-
| Playwright annotation | Yes | `{ annotation: facet(...) }` in test options |
|
|
269
|
-
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
## CLI Commands
|
|
273
|
-
|
|
274
|
-
### Generate Structure & Types
|
|
275
|
-
|
|
276
|
-
```bash
|
|
277
|
-
# Generate structure.json and facets.ts from facet documents
|
|
278
|
-
bunx facet generate <facets-dir>
|
|
279
|
-
|
|
280
|
-
# Options
|
|
281
|
-
bunx facet generate features/checkout/facets/ -o ./custom-output # Custom output dir
|
|
282
|
-
bunx facet generate features/checkout/facets/ -t business # Override type
|
|
283
|
-
bunx facet generate features/checkout/facets/ --no-types # Skip TypeScript generation
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
### Analyze Coverage
|
|
83
|
+
### 3. See coverage across all perspectives
|
|
287
84
|
|
|
288
85
|
```bash
|
|
289
|
-
# Run coverage analysis
|
|
290
86
|
bunx facet analyze
|
|
291
|
-
|
|
292
|
-
# Options
|
|
293
|
-
bunx facet analyze -c facet.config.js # Custom config
|
|
294
|
-
bunx facet analyze -f html # Specific format
|
|
295
|
-
bunx facet analyze -t 80 # Set threshold
|
|
296
|
-
bunx facet analyze --json # JSON output for CI
|
|
297
|
-
bunx facet analyze --silent # No console output
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
### Validate
|
|
301
|
-
|
|
302
|
-
```bash
|
|
303
|
-
# Validate structure and test links
|
|
304
|
-
bunx facet validate
|
|
305
|
-
|
|
306
|
-
# Options
|
|
307
|
-
bunx facet validate --strict # Require all tests linked
|
|
308
|
-
bunx facet validate --json # JSON output
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
### Watch Mode
|
|
312
|
-
|
|
313
|
-
```bash
|
|
314
|
-
# Re-run on changes
|
|
315
|
-
bunx facet watch
|
|
316
|
-
|
|
317
|
-
# Options
|
|
318
|
-
bunx facet watch -v # Validate before analysis
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
---
|
|
322
|
-
|
|
323
|
-
## Playwright Integration
|
|
324
|
-
|
|
325
|
-
> **Note:** Playwright works with [comment annotations](#method-1-comment-annotations-any-framework) and [generated types](#method-2-type-safe-with-generated-types-recommended) out of the box. This section covers the **optional** enhanced integration with a custom reporter and annotation helper.
|
|
326
|
-
|
|
327
|
-
### Why Use the Playwright Integration?
|
|
328
|
-
|
|
329
|
-
- **Automatic coverage on test run** - Coverage reports generated after `playwright test`
|
|
330
|
-
- **Runtime annotation capture** - Works with dynamic test generation
|
|
331
|
-
- **Native annotation syntax** - Uses Playwright's built-in annotation system
|
|
332
|
-
|
|
333
|
-
### Reporter Setup
|
|
334
|
-
|
|
335
|
-
```typescript
|
|
336
|
-
// playwright.config.ts
|
|
337
|
-
import { FacetCoverageReporter } from '@facet-coverage/core/playwright';
|
|
338
|
-
|
|
339
|
-
export default {
|
|
340
|
-
reporter: [
|
|
341
|
-
['html'],
|
|
342
|
-
[FacetCoverageReporter, {
|
|
343
|
-
output: {
|
|
344
|
-
dir: '.facet-coverage',
|
|
345
|
-
formats: ['json', 'html', 'markdown']
|
|
346
|
-
},
|
|
347
|
-
thresholds: {
|
|
348
|
-
global: 80,
|
|
349
|
-
byType: {
|
|
350
|
-
compliance: 100
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}]
|
|
354
|
-
]
|
|
355
|
-
};
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
### Test Annotations
|
|
359
|
-
|
|
360
|
-
```typescript
|
|
361
|
-
import { test } from '@playwright/test';
|
|
362
|
-
import { facet } from '@facet-coverage/core/playwright';
|
|
363
|
-
|
|
364
|
-
// Single facet
|
|
365
|
-
test('my test', {
|
|
366
|
-
annotation: facet('guest-checkout-flow')
|
|
367
|
-
}, async ({ page }) => {
|
|
368
|
-
// ...
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
// Multiple facets
|
|
372
|
-
test('comprehensive test', {
|
|
373
|
-
annotation: facet(
|
|
374
|
-
'guest-checkout-flow',
|
|
375
|
-
'pci-card-masking',
|
|
376
|
-
'mobile-checkout-ux'
|
|
377
|
-
)
|
|
378
|
-
}, async ({ page }) => {
|
|
379
|
-
// ...
|
|
380
|
-
});
|
|
381
87
|
```
|
|
382
88
|
|
|
383
|
-
---
|
|
384
|
-
|
|
385
|
-
## Configuration
|
|
386
|
-
|
|
387
|
-
**facet.config.js:**
|
|
388
|
-
|
|
389
|
-
```javascript
|
|
390
|
-
export default {
|
|
391
|
-
// Where structure files live
|
|
392
|
-
structureFiles: [
|
|
393
|
-
'features/**/.facet/structure.json'
|
|
394
|
-
],
|
|
395
|
-
|
|
396
|
-
// Where tests live
|
|
397
|
-
testDir: './features/**/tests',
|
|
398
|
-
testPatterns: ['**/*.spec.ts', '**/*.test.ts'],
|
|
399
|
-
|
|
400
|
-
// Validation options
|
|
401
|
-
validation: {
|
|
402
|
-
requireSourceExists: true,
|
|
403
|
-
requireSectionExists: true,
|
|
404
|
-
requireAllTestsLinked: false
|
|
405
|
-
},
|
|
406
|
-
|
|
407
|
-
// Output options
|
|
408
|
-
output: {
|
|
409
|
-
dir: '.facet-coverage',
|
|
410
|
-
formats: ['json', 'html', 'markdown']
|
|
411
|
-
},
|
|
412
|
-
|
|
413
|
-
// Coverage thresholds
|
|
414
|
-
thresholds: {
|
|
415
|
-
global: 75,
|
|
416
|
-
byType: {
|
|
417
|
-
compliance: 100,
|
|
418
|
-
business: 80,
|
|
419
|
-
ux: 70
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
89
|
```
|
|
90
|
+
Facet Coverage Report
|
|
91
|
+
Overall: 83% (5/6)
|
|
424
92
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
### Auto-Generated (Recommended)
|
|
430
|
-
|
|
431
|
-
```
|
|
432
|
-
Pattern: {filename}:{section-slug}
|
|
433
|
-
|
|
434
|
-
Examples:
|
|
435
|
-
- business:guest-purchase-flow
|
|
436
|
-
- compliance:pci-dss-payment-requirements
|
|
437
|
-
- ux:mobile-checkout-experience
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
### Custom Slugs
|
|
441
|
-
|
|
442
|
-
```json
|
|
443
|
-
{
|
|
444
|
-
"id": "guest-checkout-flow",
|
|
445
|
-
"source": {
|
|
446
|
-
"file": "facets/business.md",
|
|
447
|
-
"section": "guest-purchase-flow"
|
|
448
|
-
},
|
|
449
|
-
"type": "business"
|
|
450
|
-
}
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
### Flexible Linking
|
|
454
|
-
|
|
455
|
-
```typescript
|
|
456
|
-
// All three formats work:
|
|
457
|
-
facet('guest-checkout-flow') // Custom slug
|
|
458
|
-
facet('business:guest-purchase-flow') // Auto-generated
|
|
459
|
-
facet('facets/business.md#guest-purchase-flow') // Direct path
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
---
|
|
463
|
-
|
|
464
|
-
## Programmatic API
|
|
465
|
-
|
|
466
|
-
```typescript
|
|
467
|
-
import {
|
|
468
|
-
StructureReader,
|
|
469
|
-
TestScanner,
|
|
470
|
-
CoverageCalculator,
|
|
471
|
-
Validator,
|
|
472
|
-
JsonReporter,
|
|
473
|
-
HtmlReporter,
|
|
474
|
-
MarkdownReporter
|
|
475
|
-
} from '@facet-coverage/core';
|
|
476
|
-
|
|
477
|
-
// Read structures
|
|
478
|
-
const reader = new StructureReader();
|
|
479
|
-
const structures = await reader.readAllStructures();
|
|
480
|
-
|
|
481
|
-
// Scan tests
|
|
482
|
-
const scanner = new TestScanner();
|
|
483
|
-
const tests = await scanner.scanAllTests();
|
|
484
|
-
|
|
485
|
-
// Calculate coverage
|
|
486
|
-
const calculator = new CoverageCalculator();
|
|
487
|
-
const report = await calculator.calculateCoverage();
|
|
488
|
-
|
|
489
|
-
// Validate
|
|
490
|
-
const validator = new Validator();
|
|
491
|
-
const result = await validator.validate();
|
|
492
|
-
|
|
493
|
-
// Generate reports
|
|
494
|
-
const jsonReporter = new JsonReporter();
|
|
495
|
-
jsonReporter.write(report);
|
|
496
|
-
|
|
497
|
-
const htmlReporter = new HtmlReporter();
|
|
498
|
-
htmlReporter.write(report);
|
|
499
|
-
|
|
500
|
-
const mdReporter = new MarkdownReporter();
|
|
501
|
-
mdReporter.write(report);
|
|
93
|
+
business: 100% (1/1) ✓
|
|
94
|
+
compliance: 80% (4/5)
|
|
95
|
+
✗ pci-dss/cvv - No CVV storage
|
|
96
|
+
ux: 100% (1/1) ✓
|
|
502
97
|
```
|
|
503
98
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
## Benefits
|
|
507
|
-
|
|
508
|
-
<table>
|
|
509
|
-
<tr>
|
|
510
|
-
<td width="50%">
|
|
511
|
-
|
|
512
|
-
### For Product Owners
|
|
513
|
-
- Write in natural language
|
|
514
|
-
- Focus on business value
|
|
515
|
-
- See what's tested immediately
|
|
516
|
-
- Documentation evolves with product
|
|
517
|
-
|
|
518
|
-
### For Compliance Teams
|
|
519
|
-
- Direct regulation mapping
|
|
520
|
-
- Audit-ready traceability
|
|
521
|
-
- 100% coverage enforcement
|
|
522
|
-
- Automated compliance reports
|
|
523
|
-
|
|
524
|
-
### For UX Designers
|
|
525
|
-
- Document user flows naturally
|
|
526
|
-
- Link designs to tests
|
|
527
|
-
- Track accessibility coverage
|
|
528
|
-
- Mobile/desktop requirements clear
|
|
529
|
-
|
|
530
|
-
</td>
|
|
531
|
-
<td width="50%">
|
|
532
|
-
|
|
533
|
-
### For Developers
|
|
534
|
-
- One test covers multiple facets
|
|
535
|
-
- Clear requirements from all stakeholders
|
|
536
|
-
- Know exactly what's covered
|
|
537
|
-
- Easy maintenance
|
|
538
|
-
|
|
539
|
-
### For QA Teams
|
|
540
|
-
- Complete visibility
|
|
541
|
-
- Automated gap detection
|
|
542
|
-
- Multi-perspective coverage
|
|
543
|
-
- Progress tracking
|
|
544
|
-
|
|
545
|
-
</td>
|
|
546
|
-
</tr>
|
|
547
|
-
</table>
|
|
99
|
+
**Now you know:** The compliance team's CVV requirement isn't tested yet.
|
|
548
100
|
|
|
549
101
|
---
|
|
550
102
|
|
|
551
|
-
##
|
|
552
|
-
|
|
553
|
-
| Approach | Focus | Facet's Difference |
|
|
554
|
-
|----------|-------|-------------------|
|
|
555
|
-
| **TDD** | Code correctness via unit tests | Facet tracks *what* is covered, not *how* to write code |
|
|
556
|
-
| **BDD** | Behavior via Given-When-Then | Facet uses free-form natural language, not structured syntax |
|
|
557
|
-
| **ATDD** | Acceptance criteria drive development | Facet maps multiple perspectives to tests, not just acceptance |
|
|
558
|
-
| **Traditional Coverage** | Lines/branches executed | Facet measures *requirement* coverage, not code coverage |
|
|
559
|
-
|
|
560
|
-
**Key insight:** TDD/BDD/ATDD are *development methodologies*. Facet is a *coverage framework*. Use them together.
|
|
561
|
-
|
|
562
|
-
### Why Facet Works for AI-Driven Testing
|
|
103
|
+
## Documentation
|
|
563
104
|
|
|
564
|
-
|
|
105
|
+
| Guide | Description |
|
|
106
|
+
|-------|-------------|
|
|
107
|
+
| [Getting Started](docs/getting-started.md) | Full quickstart with project structure |
|
|
108
|
+
| [Core Concepts](docs/concepts.md) | What Facet is and how it works |
|
|
109
|
+
| [Configuration](docs/configuration.md) | Config options and examples |
|
|
110
|
+
| [CLI Reference](docs/cli.md) | All available commands |
|
|
111
|
+
| [Playwright Integration](docs/playwright.md) | Enhanced Playwright support |
|
|
112
|
+
| [Programmatic API](docs/api.md) | Use Facet in code |
|
|
113
|
+
| [ID Patterns](docs/id-patterns.md) | Stable IDs, sub-facets, and nested features |
|
|
565
114
|
|
|
566
|
-
|
|
567
|
-
- **Multi-perspective facets** → AI generates tests covering business, compliance, UX in one pass
|
|
568
|
-
- **Type-safe linking** → AI can programmatically verify coverage completeness
|
|
569
|
-
- **Gap detection** → AI identifies untested facets and generates missing tests
|
|
115
|
+
### Background
|
|
570
116
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
Facet bridges human intent and AI execution with traceable, verifiable coverage.
|
|
117
|
+
| Document | Description |
|
|
118
|
+
|----------|-------------|
|
|
119
|
+
| [Vision](docs/vision.md) | Philosophy behind multi-stakeholder coverage |
|
|
120
|
+
| [Testing Phases](docs/testing-phases.md) | Where Facet fits in testing |
|
|
121
|
+
| [Comparisons](docs/comparisons.md) | How Facet differs from BDD, Cucumber, etc. |
|
|
577
122
|
|
|
578
123
|
---
|
|
579
124
|
|
|
580
|
-
## Key
|
|
125
|
+
## Key Features
|
|
581
126
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
| **Lightweight** | Markdown + JSON, nothing heavy |
|
|
590
|
-
| **Flexible** | Adopt incrementally, customize freely |
|
|
127
|
+
- **Natural language** - Write requirements as Markdown, no Gherkin syntax
|
|
128
|
+
- **Multi-perspective** - Business, compliance, UX, technical facets per feature
|
|
129
|
+
- **Sub-facets** - Track fine-grained requirements with hierarchical IDs
|
|
130
|
+
- **Type-safe linking** - Generated TypeScript types prevent broken references
|
|
131
|
+
- **Framework agnostic** - Works with Jest, Vitest, Playwright, Mocha, Bun
|
|
132
|
+
- **Gap detection** - See what's untested across all stakeholder perspectives
|
|
133
|
+
- **CI-ready** - Threshold enforcement and JSON output for pipelines
|
|
591
134
|
|
|
592
135
|
---
|
|
593
136
|
|
|
594
137
|
## Contributing
|
|
595
138
|
|
|
596
|
-
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
139
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
597
140
|
|
|
598
141
|
1. Fork the repository
|
|
599
142
|
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
600
|
-
3. Commit your changes
|
|
143
|
+
3. Commit your changes
|
|
601
144
|
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
602
145
|
5. Open a Pull Request
|
|
603
146
|
|
|
@@ -613,6 +156,4 @@ MIT License - see the [LICENSE](LICENSE) file for details.
|
|
|
613
156
|
|
|
614
157
|
**[Report Bug](https://github.com/iraycd/facet-coverage/issues) | [Request Feature](https://github.com/iraycd/facet-coverage/issues)**
|
|
615
158
|
|
|
616
|
-
If you find this project useful, please consider giving it a star!
|
|
617
|
-
|
|
618
159
|
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/analyze.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/analyze.ts"],"names":[],"mappings":"AAOA,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwEhF"}
|