@cratis/pi 7.84.0 → 7.84.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.
|
@@ -126,6 +126,10 @@ array.should.have.lengthOf(3);
|
|
|
126
126
|
(() => throwingFn()).should.throw(ErrorType);
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
+
### Comparing JSON
|
|
130
|
+
|
|
131
|
+
Never assert JSON equality by comparing `JSON.stringify` output: object key order is insertion order, so two equal documents can serialize differently and a spec fails, or passes, for the wrong reason. Compare parsed values with `should.deep.equal`. When a helper must compare serialized JSON (a snapshot, a file on disk, a request body), canonicalize first: sort object keys recursively at every level and keep array order, because array order is data. Review flags raw `JSON.stringify(a) === JSON.stringify(b)` equality in specs and spec helpers.
|
|
132
|
+
|
|
129
133
|
## Mocking with Sinon
|
|
130
134
|
|
|
131
135
|
```typescript
|
|
@@ -125,6 +125,10 @@ array.should.have.lengthOf(3);
|
|
|
125
125
|
(() => throwingFn()).should.throw(ErrorType);
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
+
### Comparing JSON
|
|
129
|
+
|
|
130
|
+
Never assert JSON equality by comparing `JSON.stringify` output: object key order is insertion order, so two equal documents can serialize differently and a spec fails, or passes, for the wrong reason. Compare parsed values with `should.deep.equal`. When a helper must compare serialized JSON (a snapshot, a file on disk, a request body), canonicalize first: sort object keys recursively at every level and keep array order, because array order is data. Review flags raw `JSON.stringify(a) === JSON.stringify(b)` equality in specs and spec helpers.
|
|
131
|
+
|
|
128
132
|
## Mocking with Sinon
|
|
129
133
|
|
|
130
134
|
```typescript
|