@cobol-ts/test_utils 0.0.3 → 0.0.5
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAuC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs `fn`, silences all console.error calls during its execution,
|
|
3
|
+
* then restores console.error and returns what was logged.
|
|
4
|
+
*/
|
|
5
|
+
export declare function captureConsoleError<T>(fn: () => T): {
|
|
6
|
+
result: T;
|
|
7
|
+
errors: any[][];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Like `captureConsoleError`, but supports async callbacks.
|
|
11
|
+
*/
|
|
12
|
+
export declare function captureConsoleErrorAsync<T>(fn: () => Promise<T>): Promise<{
|
|
13
|
+
result: T;
|
|
14
|
+
errors: any[][];
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Runs `fn`, silences all console.log calls during its execution,
|
|
18
|
+
* then restores console.log and returns what was logged.
|
|
19
|
+
*/
|
|
20
|
+
export declare function captureConsoleLog<T>(fn: () => T): {
|
|
21
|
+
result: T;
|
|
22
|
+
logs: any[][];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Like `captureConsoleLog`, but supports async callbacks.
|
|
26
|
+
*/
|
|
27
|
+
export declare function captureConsoleLogAsync<T>(fn: () => Promise<T>): Promise<{
|
|
28
|
+
result: T;
|
|
29
|
+
logs: any[][];
|
|
30
|
+
}>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// testUtils.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.captureConsoleError = captureConsoleError;
|
|
5
|
+
exports.captureConsoleErrorAsync = captureConsoleErrorAsync;
|
|
6
|
+
exports.captureConsoleLog = captureConsoleLog;
|
|
7
|
+
exports.captureConsoleLogAsync = captureConsoleLogAsync;
|
|
8
|
+
/**
|
|
9
|
+
* Runs `fn`, silences all console.error calls during its execution,
|
|
10
|
+
* then restores console.error and returns what was logged.
|
|
11
|
+
*/
|
|
12
|
+
function captureConsoleError(fn) {
|
|
13
|
+
const originalError = console.error;
|
|
14
|
+
const errors = [];
|
|
15
|
+
console.error = (...args) => {
|
|
16
|
+
errors.push(args);
|
|
17
|
+
};
|
|
18
|
+
let result;
|
|
19
|
+
try {
|
|
20
|
+
result = fn();
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
console.error = originalError;
|
|
24
|
+
}
|
|
25
|
+
return { result, errors };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Like `captureConsoleError`, but supports async callbacks.
|
|
29
|
+
*/
|
|
30
|
+
async function captureConsoleErrorAsync(fn) {
|
|
31
|
+
const originalError = console.error;
|
|
32
|
+
const errors = [];
|
|
33
|
+
console.error = (...args) => {
|
|
34
|
+
errors.push(args);
|
|
35
|
+
};
|
|
36
|
+
let result;
|
|
37
|
+
try {
|
|
38
|
+
result = await fn();
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
console.error = originalError;
|
|
42
|
+
}
|
|
43
|
+
return { result, errors };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Runs `fn`, silences all console.log calls during its execution,
|
|
47
|
+
* then restores console.log and returns what was logged.
|
|
48
|
+
*/
|
|
49
|
+
function captureConsoleLog(fn) {
|
|
50
|
+
const originalLog = console.log;
|
|
51
|
+
const logs = [];
|
|
52
|
+
console.log = (...args) => {
|
|
53
|
+
logs.push(args);
|
|
54
|
+
};
|
|
55
|
+
let result;
|
|
56
|
+
try {
|
|
57
|
+
result = fn();
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
console.log = originalLog;
|
|
61
|
+
}
|
|
62
|
+
return { result, logs };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Like `captureConsoleLog`, but supports async callbacks.
|
|
66
|
+
*/
|
|
67
|
+
async function captureConsoleLogAsync(fn) {
|
|
68
|
+
const originalLog = console.log;
|
|
69
|
+
const logs = [];
|
|
70
|
+
console.log = (...args) => {
|
|
71
|
+
logs.push(args);
|
|
72
|
+
};
|
|
73
|
+
let result;
|
|
74
|
+
try {
|
|
75
|
+
result = await fn();
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
console.log = originalLog;
|
|
79
|
+
}
|
|
80
|
+
return { result, logs };
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=capture.error.log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.error.log.js","sourceRoot":"","sources":["../../src/capture.error.log.ts"],"names":[],"mappings":";AAAA,eAAe;;AAMf,kDAeC;AAKD,4DAiBC;AAKD,8CAeC;AAKD,wDAiBC;AAnFD;;;GAGG;AACH,SAAgB,mBAAmB,CAAI,EAAW;IAC9C,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAA;IACnC,MAAM,MAAM,GAAY,EAAE,CAAA;IAC1B,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;QAC/B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrB,CAAC,CAAA;IAED,IAAI,MAAU,CAAA;IACd,IAAI,CAAC;QACD,MAAM,GAAG,EAAE,EAAE,CAAA;IACjB,CAAC;YAAS,CAAC;QACP,OAAO,CAAC,KAAK,GAAG,aAAa,CAAA;IACjC,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AAC7B,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,wBAAwB,CAC1C,EAAoB;IAEpB,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAA;IACnC,MAAM,MAAM,GAAY,EAAE,CAAA;IAC1B,OAAO,CAAC,KAAK,GAA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AAM,EAAE,IAAI,EAAE,CAAC;AAC5B,CAAC"}
|
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.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"types": "dist/index",
|
|
7
7
|
"browserslist": {
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"files": [
|
|
45
45
|
"dist/index.js",
|
|
46
46
|
"dist/index.d.ts",
|
|
47
|
-
"dist/src/"
|
|
47
|
+
"dist/src/",
|
|
48
|
+
"dist/**/*"
|
|
48
49
|
],
|
|
49
50
|
"keywords": [
|
|
50
51
|
"indexing"
|