@cobol-ts/test_utils 0.0.13 → 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.
Files changed (2) hide show
  1. package/README.md +12 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,22 +1,20 @@
1
1
  # @cobol-ts/test_utils
2
2
 
3
- ## Purpose
3
+ Capture console errors or logs across synchronous and asynchronous test callbacks.
4
4
 
5
- Capture console messages while exercising a synchronous or asynchronous callback in tests. The API returns both the callback's result and the collected messages, avoiding repeated hand-written `console` stubs in individual test suites.
5
+ The capture helpers belong in tests and should not be used as production diagnostics.
6
6
 
7
- ## Exports
7
+ ## API
8
8
 
9
- `captureConsoleError` and `captureConsoleErrorAsync` return objects with `result` and `errors`. `captureConsoleLog` and `captureConsoleLogAsync` return `result` and `logs`. Each entry of the collected arrays contains the arguments passed to the corresponding console method.
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
- ## Example
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
- ```ts
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
- Console interception is process-global during the callback. Avoid overlapping captures in parallel tests and check the implementation's restoration semantics before using it in error-path assertions. Source: [`src/capture.error.log.ts`](src/capture.error.log.ts).
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).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cobol-ts/test_utils",
3
3
  "description": "test utilities for the @cobol-ts project",
4
- "version": "0.0.13",
4
+ "version": "0.0.16",
5
5
  "main": "dist/index",
6
6
  "types": "dist/index",
7
7
  "browserslist": {