@cobol-ts/test_utils 0.0.0-stage → 0.0.2
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 +21 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/package.json +55 -3
package/README.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cobol-ts/test_utils
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Purpose
|
|
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.
|
|
6
|
+
|
|
7
|
+
## Exports
|
|
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.
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
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
|
+
```
|
|
21
|
+
|
|
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).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/capture.error.log';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./src/capture.error.log"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobol-ts/test_utils",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "test utilities for the @cobol-ts project",
|
|
4
|
+
"version": "0.0.2",
|
|
5
|
+
"main": "dist/index",
|
|
6
|
+
"types": "dist/index",
|
|
7
|
+
"browserslist": {
|
|
8
|
+
"development": [
|
|
9
|
+
"last 1 chrome version",
|
|
10
|
+
"last 1 firefox version",
|
|
11
|
+
"last 1 safari version"
|
|
12
|
+
],
|
|
13
|
+
"production": [
|
|
14
|
+
">0.2%",
|
|
15
|
+
"not dead",
|
|
16
|
+
"not op_mini all"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"typescript": "^5.2.2",
|
|
22
|
+
"@testing-library/jest-dom": "^6.1.4",
|
|
23
|
+
"@types/jest": "^29.0.0",
|
|
24
|
+
"@types/node": "^14.0.0",
|
|
25
|
+
"jest": "^29.0.0",
|
|
26
|
+
"ts-jest": "^29.0.0"
|
|
27
|
+
},
|
|
28
|
+
"eslintConfig": {
|
|
29
|
+
"extends": [
|
|
30
|
+
"react-app",
|
|
31
|
+
"react-app/jest"
|
|
32
|
+
],
|
|
33
|
+
"overrides": [
|
|
34
|
+
{
|
|
35
|
+
"files": [
|
|
36
|
+
"**/*.stories.*"
|
|
37
|
+
],
|
|
38
|
+
"rules": {
|
|
39
|
+
"import/no-anonymous-default-export": "off"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist/index.js",
|
|
46
|
+
"dist/index.d.ts",
|
|
47
|
+
"dist/src/"
|
|
48
|
+
],
|
|
49
|
+
"keywords": [
|
|
50
|
+
"indexing"
|
|
51
|
+
],
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"repository": "git@github.com:intellimaintain/intellimaintain.git",
|
|
54
|
+
"scripts": {
|
|
55
|
+
"test": "jest --config jest.config.json --env node",
|
|
56
|
+
"test:watch": "npm run test -- --watch"
|
|
57
|
+
}
|
|
6
58
|
}
|