@testomatio/reporter 2.0.1-beta.3 → 2.0.1-beta.5-timestamp
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/lib/adapter/codecept.js +335 -293
- package/lib/adapter/cucumber/current.js +203 -195
- package/lib/adapter/cucumber/legacy.js +155 -130
- package/lib/adapter/cucumber.js +16 -5
- package/lib/adapter/cypress-plugin/index.js +105 -91
- package/lib/adapter/jasmine.js +53 -54
- package/lib/adapter/jest.js +99 -97
- package/lib/adapter/mocha.js +141 -112
- package/lib/adapter/playwright.js +231 -199
- package/lib/adapter/vitest.js +149 -150
- package/lib/adapter/webdriver.js +121 -144
- package/lib/bin/cli.js +211 -229
- package/lib/bin/reportXml.js +52 -51
- package/lib/bin/startTest.js +95 -83
- package/lib/bin/uploadArtifacts.js +61 -56
- package/lib/client.js +465 -424
- package/lib/config.js +23 -18
- package/lib/constants.js +44 -50
- package/lib/data-storage.js +188 -216
- package/lib/junit-adapter/adapter.js +20 -17
- package/lib/junit-adapter/csharp.js +14 -28
- package/lib/junit-adapter/index.js +25 -27
- package/lib/junit-adapter/java.js +53 -41
- package/lib/junit-adapter/javascript.js +27 -30
- package/lib/junit-adapter/python.js +37 -38
- package/lib/junit-adapter/ruby.js +8 -11
- package/lib/output.js +52 -44
- package/lib/pipe/bitbucket.js +230 -223
- package/lib/pipe/csv.js +126 -113
- package/lib/pipe/debug.js +99 -118
- package/lib/pipe/github.js +213 -218
- package/lib/pipe/gitlab.js +206 -183
- package/lib/pipe/html.js +321 -258
- package/lib/pipe/index.js +66 -94
- package/lib/pipe/testomatio.js +474 -429
- package/lib/reporter-functions.js +26 -28
- package/lib/reporter.js +29 -34
- package/lib/services/artifacts.js +51 -55
- package/lib/services/index.js +12 -14
- package/lib/services/key-values.js +53 -56
- package/lib/services/logger.js +245 -226
- package/lib/template/testomatio.hbs +1366 -1026
- package/lib/uploader.js +364 -295
- package/lib/utils/pipe_utils.js +85 -89
- package/lib/utils/utils.js +307 -398
- package/lib/xmlReader.js +532 -525
- package/package.json +21 -64
- package/lib/adapter/codecept.d.ts +0 -2
- package/lib/adapter/cucumber/current.d.ts +0 -14
- package/lib/adapter/cucumber/legacy.d.ts +0 -0
- package/lib/adapter/cucumber.d.ts +0 -2
- package/lib/adapter/cypress-plugin/index.d.ts +0 -2
- package/lib/adapter/jasmine.d.ts +0 -11
- package/lib/adapter/jest.d.ts +0 -13
- package/lib/adapter/mocha.d.ts +0 -2
- package/lib/adapter/nightwatch.d.ts +0 -4
- package/lib/adapter/nightwatch.js +0 -80
- package/lib/adapter/playwright.d.ts +0 -14
- package/lib/adapter/vitest.d.ts +0 -35
- package/lib/adapter/webdriver.d.ts +0 -24
- package/lib/bin/cli.d.ts +0 -2
- package/lib/bin/reportXml.d.ts +0 -2
- package/lib/bin/startTest.d.ts +0 -2
- package/lib/bin/uploadArtifacts.d.ts +0 -2
- package/lib/client.d.ts +0 -76
- package/lib/config.d.ts +0 -1
- package/lib/constants.d.ts +0 -25
- package/lib/data-storage.d.ts +0 -34
- package/lib/junit-adapter/adapter.d.ts +0 -9
- package/lib/junit-adapter/csharp.d.ts +0 -5
- package/lib/junit-adapter/index.d.ts +0 -3
- package/lib/junit-adapter/java.d.ts +0 -5
- package/lib/junit-adapter/javascript.d.ts +0 -4
- package/lib/junit-adapter/python.d.ts +0 -5
- package/lib/junit-adapter/ruby.d.ts +0 -4
- package/lib/output.d.ts +0 -11
- package/lib/package.json +0 -3
- package/lib/pipe/bitbucket.d.ts +0 -25
- package/lib/pipe/csv.d.ts +0 -47
- package/lib/pipe/debug.d.ts +0 -29
- package/lib/pipe/github.d.ts +0 -30
- package/lib/pipe/gitlab.d.ts +0 -25
- package/lib/pipe/html.d.ts +0 -35
- package/lib/pipe/index.d.ts +0 -1
- package/lib/pipe/testomatio.d.ts +0 -71
- package/lib/replay.d.ts +0 -31
- package/lib/replay.js +0 -237
- package/lib/reporter-functions.d.ts +0 -34
- package/lib/reporter.d.ts +0 -232
- package/lib/services/artifacts.d.ts +0 -33
- package/lib/services/index.d.ts +0 -9
- package/lib/services/key-values.d.ts +0 -27
- package/lib/services/logger.d.ts +0 -64
- package/lib/uploader.d.ts +0 -60
- package/lib/utils/pipe_utils.d.ts +0 -41
- package/lib/utils/utils.d.ts +0 -54
- package/lib/xmlReader.d.ts +0 -92
- package/src/adapter/codecept.js +0 -373
- package/src/adapter/cucumber/current.js +0 -228
- package/src/adapter/cucumber/legacy.js +0 -158
- package/src/adapter/cucumber.js +0 -4
- package/src/adapter/cypress-plugin/index.js +0 -110
- package/src/adapter/jasmine.js +0 -60
- package/src/adapter/jest.js +0 -107
- package/src/adapter/mocha.cjs +0 -2
- package/src/adapter/mocha.js +0 -156
- package/src/adapter/nightwatch.js +0 -88
- package/src/adapter/playwright.js +0 -254
- package/src/adapter/vitest.js +0 -183
- package/src/adapter/webdriver.js +0 -142
- package/src/bin/cli.js +0 -348
- package/src/bin/reportXml.js +0 -77
- package/src/bin/startTest.js +0 -124
- package/src/bin/uploadArtifacts.js +0 -91
- package/src/client.js +0 -508
- package/src/config.js +0 -30
- package/src/constants.js +0 -53
- package/src/data-storage.js +0 -204
- package/src/junit-adapter/adapter.js +0 -23
- package/src/junit-adapter/csharp.js +0 -28
- package/src/junit-adapter/index.js +0 -28
- package/src/junit-adapter/java.js +0 -58
- package/src/junit-adapter/javascript.js +0 -31
- package/src/junit-adapter/python.js +0 -42
- package/src/junit-adapter/ruby.js +0 -10
- package/src/output.js +0 -57
- package/src/pipe/bitbucket.js +0 -252
- package/src/pipe/csv.js +0 -140
- package/src/pipe/debug.js +0 -119
- package/src/pipe/github.js +0 -232
- package/src/pipe/gitlab.js +0 -247
- package/src/pipe/html.js +0 -373
- package/src/pipe/index.js +0 -71
- package/src/pipe/testomatio.js +0 -504
- package/src/replay.js +0 -245
- package/src/reporter-functions.js +0 -55
- package/src/reporter.cjs_decprecated +0 -21
- package/src/reporter.js +0 -33
- package/src/services/artifacts.js +0 -59
- package/src/services/index.js +0 -13
- package/src/services/key-values.js +0 -59
- package/src/services/logger.js +0 -315
- package/src/template/emptyData.svg +0 -23
- package/src/template/testomatio.hbs +0 -1081
- package/src/uploader.js +0 -376
- package/src/utils/pipe_utils.js +0 -119
- package/src/utils/utils.js +0 -416
- package/src/xmlReader.js +0 -614
|
@@ -1,30 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const suite = t.suite_title.split('.');
|
|
15
|
-
t.suite_title = suite.pop();
|
|
16
|
-
t.file = namespaceToFileName(t.file);
|
|
17
|
-
t.title = title.trim();
|
|
18
|
-
return t;
|
|
19
|
-
}
|
|
20
|
-
getFilePath(t) {
|
|
21
|
-
const fileName = namespaceToFileName(t.file);
|
|
22
|
-
return fileName;
|
|
23
|
-
}
|
|
1
|
+
const Adapter = require('./adapter');
|
|
2
|
+
|
|
3
|
+
class CSharpAdapter extends Adapter {
|
|
4
|
+
formatTest(t) {
|
|
5
|
+
const title = t.title.replace(/\(.*?\)/, '').trim();
|
|
6
|
+
const example = t.title.match(/\((.*?)\)/);
|
|
7
|
+
if (example) t.example = { ...example[1].split(',') };
|
|
8
|
+
const suite = t.suite_title.split('.');
|
|
9
|
+
t.suite_title = suite.pop();
|
|
10
|
+
t.file = suite.join('/');
|
|
11
|
+
t.title = title.trim();
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
24
14
|
}
|
|
15
|
+
|
|
25
16
|
module.exports = CSharpAdapter;
|
|
26
|
-
function namespaceToFileName(fileName) {
|
|
27
|
-
const fileParts = fileName.split('.');
|
|
28
|
-
fileParts[fileParts.length - 1] = fileParts[fileParts.length - 1]?.replace(/\$.*/, '');
|
|
29
|
-
return `${fileParts.join(path_1.default.sep)}.cs`;
|
|
30
|
-
}
|
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const java_js_1 = __importDefault(require("./java.js"));
|
|
9
|
-
const python_js_1 = __importDefault(require("./python.js"));
|
|
10
|
-
const ruby_js_1 = __importDefault(require("./ruby.js"));
|
|
11
|
-
const csharp_js_1 = __importDefault(require("./csharp.js"));
|
|
1
|
+
const Adapter = require('./adapter');
|
|
2
|
+
const JavaScriptAdapter = require('./javascript');
|
|
3
|
+
const JavaAdapter = require('./java');
|
|
4
|
+
const PythonAdapter = require('./python');
|
|
5
|
+
const RubyAdapter = require('./ruby');
|
|
6
|
+
const CSharpAdapter = require('./csharp');
|
|
7
|
+
|
|
12
8
|
function AdapterFactory(lang, opts) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
if (lang === 'java') {
|
|
10
|
+
return new JavaAdapter(opts);
|
|
11
|
+
}
|
|
12
|
+
if (lang === 'js') {
|
|
13
|
+
return new JavaScriptAdapter(opts);
|
|
14
|
+
}
|
|
15
|
+
if (lang === 'python') {
|
|
16
|
+
return new PythonAdapter(opts);
|
|
17
|
+
}
|
|
18
|
+
if (lang === 'ruby') {
|
|
19
|
+
return new RubyAdapter(opts);
|
|
20
|
+
}
|
|
21
|
+
if (lang === 'c#' || lang === 'csharp') {
|
|
22
|
+
return new CSharpAdapter(opts);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return new Adapter(opts);
|
|
29
26
|
}
|
|
27
|
+
|
|
30
28
|
module.exports = AdapterFactory;
|
|
@@ -1,46 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
t.example = example;
|
|
36
|
-
}
|
|
37
|
-
t.suite_title = fileParts[fileParts.length - 1].replace(/\$/g, ' | ');
|
|
38
|
-
return t;
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const Adapter = require('./adapter');
|
|
3
|
+
|
|
4
|
+
class JavaAdapter extends Adapter {
|
|
5
|
+
getFilePath(t) {
|
|
6
|
+
const fileName = namespaceToFileName(t.suite_title);
|
|
7
|
+
return this.opts.javaTests + path.sep + fileName;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
formatTest(t) {
|
|
11
|
+
const fileParts = t.suite_title.split('.');
|
|
12
|
+
|
|
13
|
+
t.file = namespaceToFileName(t.suite_title);
|
|
14
|
+
t.title = t.title.split('(')[0];
|
|
15
|
+
|
|
16
|
+
// detect params
|
|
17
|
+
const paramMatches = t.title.match(/\[(.*?)\]/g);
|
|
18
|
+
|
|
19
|
+
if (paramMatches) {
|
|
20
|
+
const params = paramMatches.map((_match, index) => `param${index + 1}`);
|
|
21
|
+
if (params.length === 1) params[0] = 'param';
|
|
22
|
+
let paramIndex = 0;
|
|
23
|
+
|
|
24
|
+
t.title = t.title.replace(/: \[(.*?)\]/g, () => {
|
|
25
|
+
if (params.length < 2) return `\${param}`;
|
|
26
|
+
const paramName = params[paramIndex] || `param${paramIndex + 1}`;
|
|
27
|
+
paramIndex++;
|
|
28
|
+
return `\${${paramName}}`;
|
|
29
|
+
});
|
|
30
|
+
const example = {};
|
|
31
|
+
paramMatches.forEach((match, index) => {
|
|
32
|
+
example[params[index]] = match.replace(/[[\]]/g, '');
|
|
33
|
+
});
|
|
34
|
+
t.example = example;
|
|
39
35
|
}
|
|
36
|
+
|
|
37
|
+
t.suite_title = fileParts[fileParts.length - 1].replace(/\$/g, ' | ');
|
|
38
|
+
return t;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// formatStack(t) {
|
|
42
|
+
// const stack = super.formatStack(t);
|
|
43
|
+
|
|
44
|
+
// const file = t.suite_title.split('.');
|
|
45
|
+
|
|
46
|
+
// const fileLine = `at .*${file[file.length - 1]}\.java:(\\d+)` // eslint-disable-line no-useless-escape
|
|
47
|
+
// const regexp = new RegExp(fileLine,"g")
|
|
48
|
+
// return stack.replace(regexp, `${this.opts.javaTests}${path.sep}${namespaceToFileName(t.suite_title)}:$1:`);
|
|
49
|
+
// }
|
|
40
50
|
}
|
|
51
|
+
|
|
41
52
|
function namespaceToFileName(fileName) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
const fileParts = fileName.split('.');
|
|
54
|
+
fileParts[fileParts.length - 1] = fileParts[fileParts.length - 1]?.replace(/\$.*/, '');
|
|
55
|
+
return `${fileParts.join(path.sep)}.java`;
|
|
45
56
|
}
|
|
57
|
+
|
|
46
58
|
module.exports = JavaAdapter;
|
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return stack;
|
|
27
|
-
}
|
|
28
|
-
catch (err) {
|
|
29
|
-
return stack;
|
|
30
|
-
}
|
|
1
|
+
const createCallsiteRecord = require('callsite-record');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const Adapter = require('./adapter');
|
|
4
|
+
|
|
5
|
+
class JavaScriptAdapter extends Adapter {
|
|
6
|
+
formatStack(t) {
|
|
7
|
+
let stack = super.formatStack(t);
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
const error = new Error(stack.split('\n')[0]);
|
|
11
|
+
error.stack = stack;
|
|
12
|
+
const record = createCallsiteRecord({
|
|
13
|
+
forError: error,
|
|
14
|
+
});
|
|
15
|
+
if (record && !record.filename.startsWith('http')) {
|
|
16
|
+
stack += record.renderSync({
|
|
17
|
+
stackFilter: frame =>
|
|
18
|
+
frame.getFileName().indexOf(path.sep) > -1 &&
|
|
19
|
+
frame.getFileName().indexOf('node_modules') < 0 &&
|
|
20
|
+
frame.getFileName().indexOf('internal') < 0,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return stack;
|
|
24
|
+
} catch (err) {
|
|
25
|
+
return stack;
|
|
31
26
|
}
|
|
27
|
+
}
|
|
32
28
|
}
|
|
29
|
+
|
|
33
30
|
module.exports = JavaScriptAdapter;
|
|
@@ -1,43 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
formatMessage(t) {
|
|
27
|
-
return t.message.split(' ')[0];
|
|
28
|
-
}
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const Adapter = require('./adapter');
|
|
4
|
+
|
|
5
|
+
class PythonAdapter extends Adapter {
|
|
6
|
+
getFilePath(t) {
|
|
7
|
+
let fileName = namespaceToFileName(t.suite_title, { checkFile: true });
|
|
8
|
+
if (!fileName) fileName = namespaceToFileName(t.suite_title, { checkFile: false });
|
|
9
|
+
return fileName;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
formatTest(t) {
|
|
13
|
+
const fileParts = t.suite_title.split('.');
|
|
14
|
+
const example = t.title.match(/\[(.*)\]/)?.[1];
|
|
15
|
+
if (example) t.example = { '#': example };
|
|
16
|
+
|
|
17
|
+
t.file = namespaceToFileName(t.suite_title);
|
|
18
|
+
t.title = t.title.split('[')[0];
|
|
19
|
+
t.suite_title = fileParts[fileParts.length - 1].replace(/\$/g, ' | ');
|
|
20
|
+
return t;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
formatMessage(t) {
|
|
24
|
+
return t.message.split(' ')[0];
|
|
25
|
+
}
|
|
29
26
|
}
|
|
27
|
+
|
|
30
28
|
function namespaceToFileName(fileName, opts = {}) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
fileParts.pop();
|
|
29
|
+
const fileParts = fileName.split('.');
|
|
30
|
+
|
|
31
|
+
while (fileParts.length > 0) {
|
|
32
|
+
const file = `${fileParts.join(path.sep)}.py`;
|
|
33
|
+
if (!opts.checkFile) return file;
|
|
34
|
+
if (fs.existsSync(`${fileParts.join(path.sep)}.py`)) {
|
|
35
|
+
return file;
|
|
40
36
|
}
|
|
41
|
-
|
|
37
|
+
fileParts.pop();
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
42
40
|
}
|
|
41
|
+
|
|
43
42
|
module.exports = PythonAdapter;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
formatStack(t) {
|
|
9
|
-
const stack = super.formatStack(t);
|
|
10
|
-
return stack.replace(/\[(.*?:.\d*)\]/g, '\n$1');
|
|
11
|
-
}
|
|
1
|
+
const Adapter = require('./adapter');
|
|
2
|
+
|
|
3
|
+
class RubyAdapter extends Adapter {
|
|
4
|
+
formatStack(t) {
|
|
5
|
+
const stack = super.formatStack(t);
|
|
6
|
+
return stack.replace(/\[(.*?:.\d*)\]/g, '\n$1');
|
|
7
|
+
}
|
|
12
8
|
}
|
|
9
|
+
|
|
13
10
|
module.exports = RubyAdapter;
|
package/lib/output.js
CHANGED
|
@@ -1,49 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const util_1 = require("util");
|
|
1
|
+
const { format } = require('util');
|
|
2
|
+
|
|
4
3
|
const consoleLog = console.log;
|
|
5
4
|
const consoleError = console.error;
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
const formatArgs = args => format.apply(format, Array.prototype.slice.call(args));
|
|
7
|
+
|
|
7
8
|
class Output {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
9
|
+
constructor(opts = {}) {
|
|
10
|
+
this.filterFn = opts.filterFn || (() => true);
|
|
11
|
+
this.reset();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
reset() {
|
|
15
|
+
this.log = [];
|
|
16
|
+
this.stop(); // resotre console log if it was overridden
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
start() {
|
|
20
|
+
const { filterFn } = this;
|
|
21
|
+
const self = this;
|
|
22
|
+
console.log = (...args) => {
|
|
23
|
+
const obj = {};
|
|
24
|
+
Error.captureStackTrace(obj);
|
|
25
|
+
const logString = formatArgs(args);
|
|
26
|
+
if (filterFn(obj.stack)) {
|
|
27
|
+
self.log.push(logString);
|
|
28
|
+
}
|
|
29
|
+
consoleLog(logString);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
console.error = (...args) => {
|
|
33
|
+
const obj = {};
|
|
34
|
+
Error.captureStackTrace(obj);
|
|
35
|
+
const logString = formatArgs(args);
|
|
36
|
+
if (filterFn(obj.stack)) {
|
|
37
|
+
self.log.push(logString);
|
|
38
|
+
}
|
|
39
|
+
consoleError(logString);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
push(line) {
|
|
44
|
+
this.log.push(line);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
text() {
|
|
48
|
+
return this.log.join('\n');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
stop() {
|
|
52
|
+
console.log = consoleLog;
|
|
53
|
+
console.error = consoleError;
|
|
54
|
+
}
|
|
48
55
|
}
|
|
56
|
+
|
|
49
57
|
module.exports = Output;
|