Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
339129990c |
@@ -53,7 +53,7 @@ assessed. Reports use the `@extant2000/evidence-record` format.
|
||||
|
||||
```ts
|
||||
import { assertShape, expectFields, assertFields, formatFields, coverage, formatCoverage } from '@extant2000/contract-check'
|
||||
import { z } from 'zod' // or any parser with a zod-style safeParse
|
||||
import { z } from 'zod' // npm install zod, or use any parser with a zod-style safeParse
|
||||
|
||||
// 1. Response shape
|
||||
const payload: unknown = { id: 'm1', name: 'Survey' } // e.g. a parsed response body
|
||||
@@ -68,7 +68,7 @@ const expectations = [
|
||||
]
|
||||
const result = expectFields(subscription, expectations)
|
||||
console.log(formatFields(result, { context: 'stripe.subscriptions.create', expectations }))
|
||||
assertFields(subscription, expectations, 'stripe.subscriptions.create') // or throw
|
||||
// assertFields(subscription, expectations, 'stripe.subscriptions.create') // throws ContractDriftError here instead
|
||||
|
||||
// 3. Coverage against a floor
|
||||
const c = coverage(['GET /a', 'GET /b', 'POST /c', 'GET /d'], ['GET /a', 'GET /b', 'POST /c'], 80)
|
||||
|
||||
Reference in New Issue
Block a user