@cobol-ts/test_utils 0.0.14 → 0.0.16
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 +12 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
# @cobol-ts/test_utils
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Capture console errors or logs across synchronous and asynchronous test callbacks.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The capture helpers belong in tests and should not be used as production diagnostics.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## API
|
|
8
8
|
|
|
9
|
-
`captureConsoleError`
|
|
9
|
+
- `captureConsoleError(fn)` / `captureConsoleLog(fn)` capture the respective console method around a synchronous callback.
|
|
10
|
+
- `captureConsoleErrorAsync(fn)` / `captureConsoleLogAsync(fn)` do the same for a Promise-returning callback.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
Each returns the callback `result` with an `errors` or `logs` array containing the captured argument tuples. Console methods are restored after the callback; avoid concurrent capture tests that mutate the same global console method.
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
import {captureConsoleLog} from '@cobol-ts/test_utils';
|
|
15
|
-
const {result, logs} = captureConsoleLog(() => {
|
|
16
|
-
console.log('processed', 3);
|
|
17
|
-
return 3;
|
|
18
|
-
});
|
|
19
|
-
// result === 3; logs[0] contains ['processed', 3]
|
|
20
|
-
```
|
|
14
|
+
## Source and tests
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
**Public entry points:** [capture.error.log.ts](./src/capture.error.log.ts).
|
|
17
|
+
|
|
18
|
+
**Tests:** No package-local test suite; exercised through dependent module tests.
|
|
19
|
+
|
|
20
|
+
**Related:** [@cobol-ts/debug](../debug/README.md) · [@cobol-ts/errors](../errors/README.md).
|