@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.
Files changed (148) hide show
  1. package/lib/adapter/codecept.js +335 -293
  2. package/lib/adapter/cucumber/current.js +203 -195
  3. package/lib/adapter/cucumber/legacy.js +155 -130
  4. package/lib/adapter/cucumber.js +16 -5
  5. package/lib/adapter/cypress-plugin/index.js +105 -91
  6. package/lib/adapter/jasmine.js +53 -54
  7. package/lib/adapter/jest.js +99 -97
  8. package/lib/adapter/mocha.js +141 -112
  9. package/lib/adapter/playwright.js +231 -199
  10. package/lib/adapter/vitest.js +149 -150
  11. package/lib/adapter/webdriver.js +121 -144
  12. package/lib/bin/cli.js +211 -229
  13. package/lib/bin/reportXml.js +52 -51
  14. package/lib/bin/startTest.js +95 -83
  15. package/lib/bin/uploadArtifacts.js +61 -56
  16. package/lib/client.js +465 -424
  17. package/lib/config.js +23 -18
  18. package/lib/constants.js +44 -50
  19. package/lib/data-storage.js +188 -216
  20. package/lib/junit-adapter/adapter.js +20 -17
  21. package/lib/junit-adapter/csharp.js +14 -28
  22. package/lib/junit-adapter/index.js +25 -27
  23. package/lib/junit-adapter/java.js +53 -41
  24. package/lib/junit-adapter/javascript.js +27 -30
  25. package/lib/junit-adapter/python.js +37 -38
  26. package/lib/junit-adapter/ruby.js +8 -11
  27. package/lib/output.js +52 -44
  28. package/lib/pipe/bitbucket.js +230 -223
  29. package/lib/pipe/csv.js +126 -113
  30. package/lib/pipe/debug.js +99 -118
  31. package/lib/pipe/github.js +213 -218
  32. package/lib/pipe/gitlab.js +206 -183
  33. package/lib/pipe/html.js +321 -258
  34. package/lib/pipe/index.js +66 -94
  35. package/lib/pipe/testomatio.js +474 -429
  36. package/lib/reporter-functions.js +26 -28
  37. package/lib/reporter.js +29 -34
  38. package/lib/services/artifacts.js +51 -55
  39. package/lib/services/index.js +12 -14
  40. package/lib/services/key-values.js +53 -56
  41. package/lib/services/logger.js +245 -226
  42. package/lib/template/testomatio.hbs +1366 -1026
  43. package/lib/uploader.js +364 -295
  44. package/lib/utils/pipe_utils.js +85 -89
  45. package/lib/utils/utils.js +307 -398
  46. package/lib/xmlReader.js +532 -525
  47. package/package.json +21 -64
  48. package/lib/adapter/codecept.d.ts +0 -2
  49. package/lib/adapter/cucumber/current.d.ts +0 -14
  50. package/lib/adapter/cucumber/legacy.d.ts +0 -0
  51. package/lib/adapter/cucumber.d.ts +0 -2
  52. package/lib/adapter/cypress-plugin/index.d.ts +0 -2
  53. package/lib/adapter/jasmine.d.ts +0 -11
  54. package/lib/adapter/jest.d.ts +0 -13
  55. package/lib/adapter/mocha.d.ts +0 -2
  56. package/lib/adapter/nightwatch.d.ts +0 -4
  57. package/lib/adapter/nightwatch.js +0 -80
  58. package/lib/adapter/playwright.d.ts +0 -14
  59. package/lib/adapter/vitest.d.ts +0 -35
  60. package/lib/adapter/webdriver.d.ts +0 -24
  61. package/lib/bin/cli.d.ts +0 -2
  62. package/lib/bin/reportXml.d.ts +0 -2
  63. package/lib/bin/startTest.d.ts +0 -2
  64. package/lib/bin/uploadArtifacts.d.ts +0 -2
  65. package/lib/client.d.ts +0 -76
  66. package/lib/config.d.ts +0 -1
  67. package/lib/constants.d.ts +0 -25
  68. package/lib/data-storage.d.ts +0 -34
  69. package/lib/junit-adapter/adapter.d.ts +0 -9
  70. package/lib/junit-adapter/csharp.d.ts +0 -5
  71. package/lib/junit-adapter/index.d.ts +0 -3
  72. package/lib/junit-adapter/java.d.ts +0 -5
  73. package/lib/junit-adapter/javascript.d.ts +0 -4
  74. package/lib/junit-adapter/python.d.ts +0 -5
  75. package/lib/junit-adapter/ruby.d.ts +0 -4
  76. package/lib/output.d.ts +0 -11
  77. package/lib/package.json +0 -3
  78. package/lib/pipe/bitbucket.d.ts +0 -25
  79. package/lib/pipe/csv.d.ts +0 -47
  80. package/lib/pipe/debug.d.ts +0 -29
  81. package/lib/pipe/github.d.ts +0 -30
  82. package/lib/pipe/gitlab.d.ts +0 -25
  83. package/lib/pipe/html.d.ts +0 -35
  84. package/lib/pipe/index.d.ts +0 -1
  85. package/lib/pipe/testomatio.d.ts +0 -71
  86. package/lib/replay.d.ts +0 -31
  87. package/lib/replay.js +0 -237
  88. package/lib/reporter-functions.d.ts +0 -34
  89. package/lib/reporter.d.ts +0 -232
  90. package/lib/services/artifacts.d.ts +0 -33
  91. package/lib/services/index.d.ts +0 -9
  92. package/lib/services/key-values.d.ts +0 -27
  93. package/lib/services/logger.d.ts +0 -64
  94. package/lib/uploader.d.ts +0 -60
  95. package/lib/utils/pipe_utils.d.ts +0 -41
  96. package/lib/utils/utils.d.ts +0 -54
  97. package/lib/xmlReader.d.ts +0 -92
  98. package/src/adapter/codecept.js +0 -373
  99. package/src/adapter/cucumber/current.js +0 -228
  100. package/src/adapter/cucumber/legacy.js +0 -158
  101. package/src/adapter/cucumber.js +0 -4
  102. package/src/adapter/cypress-plugin/index.js +0 -110
  103. package/src/adapter/jasmine.js +0 -60
  104. package/src/adapter/jest.js +0 -107
  105. package/src/adapter/mocha.cjs +0 -2
  106. package/src/adapter/mocha.js +0 -156
  107. package/src/adapter/nightwatch.js +0 -88
  108. package/src/adapter/playwright.js +0 -254
  109. package/src/adapter/vitest.js +0 -183
  110. package/src/adapter/webdriver.js +0 -142
  111. package/src/bin/cli.js +0 -348
  112. package/src/bin/reportXml.js +0 -77
  113. package/src/bin/startTest.js +0 -124
  114. package/src/bin/uploadArtifacts.js +0 -91
  115. package/src/client.js +0 -508
  116. package/src/config.js +0 -30
  117. package/src/constants.js +0 -53
  118. package/src/data-storage.js +0 -204
  119. package/src/junit-adapter/adapter.js +0 -23
  120. package/src/junit-adapter/csharp.js +0 -28
  121. package/src/junit-adapter/index.js +0 -28
  122. package/src/junit-adapter/java.js +0 -58
  123. package/src/junit-adapter/javascript.js +0 -31
  124. package/src/junit-adapter/python.js +0 -42
  125. package/src/junit-adapter/ruby.js +0 -10
  126. package/src/output.js +0 -57
  127. package/src/pipe/bitbucket.js +0 -252
  128. package/src/pipe/csv.js +0 -140
  129. package/src/pipe/debug.js +0 -119
  130. package/src/pipe/github.js +0 -232
  131. package/src/pipe/gitlab.js +0 -247
  132. package/src/pipe/html.js +0 -373
  133. package/src/pipe/index.js +0 -71
  134. package/src/pipe/testomatio.js +0 -504
  135. package/src/replay.js +0 -245
  136. package/src/reporter-functions.js +0 -55
  137. package/src/reporter.cjs_decprecated +0 -21
  138. package/src/reporter.js +0 -33
  139. package/src/services/artifacts.js +0 -59
  140. package/src/services/index.js +0 -13
  141. package/src/services/key-values.js +0 -59
  142. package/src/services/logger.js +0 -315
  143. package/src/template/emptyData.svg +0 -23
  144. package/src/template/testomatio.hbs +0 -1081
  145. package/src/uploader.js +0 -376
  146. package/src/utils/pipe_utils.js +0 -119
  147. package/src/utils/utils.js +0 -416
  148. package/src/xmlReader.js +0 -614
@@ -1,204 +0,0 @@
1
- import createDebugMessages from 'debug';
2
- import fs from 'fs';
3
- import path, { join } from 'path';
4
- import os from 'os';
5
- import { TESTOMAT_TMP_STORAGE_DIR } from './constants.js';
6
- import { fileSystem, testRunnerHelper } from './utils/utils.js';
7
- import crypto from 'crypto';
8
-
9
- const debug = createDebugMessages('@testomatio/reporter:storage');
10
- class DataStorage {
11
- static #instance;
12
-
13
- context;
14
-
15
- /**
16
- *
17
- * @returns {DataStorage}
18
- */
19
- static getInstance() {
20
- if (!this.#instance) {
21
- this.#instance = new DataStorage();
22
- }
23
- return this.#instance;
24
- }
25
-
26
- setContext(context) {
27
- this.context = context;
28
- }
29
-
30
- /**
31
- * Creates data storage instance as singleton
32
- * Stores data to global variable or to file depending on what is applicable for current test runner (adapter)
33
- * Recommend to use composition while using this class (instead of inheritance).
34
- * ! Also the class which will use data storage should be singleton (to avoid data loss).
35
- */
36
- constructor() {
37
- // some frameworks use global variable to store data, some use file storage
38
- this.isFileStorage = true;
39
- }
40
-
41
- /**
42
- * Puts any data to storage (file or global variable).
43
- * If file: stores data as text, if global variable – stores as array of data.
44
- * @param {'log' | 'artifact' | 'keyvalue'} dataType
45
- * @param {*} data anything you want to store (string, object, array, etc)
46
- * @param {*} context could be testId or any context (test name, suite name, including their IDs etc)
47
- * suite name + test name is used by default
48
- * @returns
49
- */
50
- putData(dataType, data, context = null) {
51
- if (!dataType || !data) return;
52
-
53
- context = context || this.context || testRunnerHelper.getNameOfCurrentlyRunningTest();
54
- if (!context) {
55
- // debug(`No context provided for "${dataType}" data:`, data);
56
- return;
57
- }
58
- const contextHash = stringToMD5Hash(context);
59
-
60
- if (this.isFileStorage) {
61
- const dataDirPath = path.join(TESTOMAT_TMP_STORAGE_DIR, dataType);
62
- fileSystem.createDir(dataDirPath);
63
- this.#putDataToFile(dataType, data, contextHash);
64
- } else {
65
- this.#putDataToGlobalVar(dataType, data, contextHash);
66
- }
67
- }
68
-
69
- /**
70
- * Returns data, stored for specific test/context (or data which was stored without test id specified).
71
- * This method will get data from global variable and/or from from file (previosly saved with put method).
72
- *
73
- * @param {'log' | 'artifact' | 'keyvalue'} dataType
74
- * @param {string} context
75
- * @returns {any []} array of data (any type), null (if no data found for context) or string (if data type is log)
76
- */
77
- getData(dataType, context) {
78
- // TODO: think if it could be useful
79
- // context = context || this.context || testRunnerHelper.getNameOfCurrentlyRunningTest();
80
-
81
- if (!context) {
82
- debug(`Trying to get "${dataType}" data without context`);
83
- return null;
84
- }
85
-
86
- const contextHash = stringToMD5Hash(context);
87
-
88
- let testDataFromFile = [];
89
- let testDataFromGlobalVar = [];
90
-
91
- if (global?.testomatioDataStore) {
92
- testDataFromGlobalVar = this.#getDataFromGlobalVar(dataType, contextHash);
93
- if (testDataFromGlobalVar) {
94
- if (testDataFromGlobalVar.length) return testDataFromGlobalVar;
95
- }
96
- // don't return nothing if no data in global variable
97
- }
98
-
99
- testDataFromFile = this.#getDataFromFile(dataType, contextHash);
100
-
101
- if (testDataFromFile.length) {
102
- return testDataFromFile;
103
- }
104
- // debug(`No "${dataType}" data for context "${contextHash}" in both file and global variable`);
105
-
106
- // in case no data found for context
107
- return null;
108
- }
109
-
110
- /**
111
- * @param {'log' | 'artifact' | 'keyvalue'} dataType
112
- * @param {string} context
113
- * @returns aray of data (any type)
114
- */
115
- #getDataFromGlobalVar(dataType, context) {
116
- try {
117
- if (global?.testomatioDataStore[dataType]) {
118
- const testData = global.testomatioDataStore[dataType][context];
119
- if (testData) debug(`"${dataType}" data for constext "${context}":`, testData.join(', '));
120
- return testData || [];
121
- }
122
- // debug(`No ${this.dataType} data for context ${context} in <global> storage`);
123
- return [];
124
- } catch (e) {
125
- // there could be no data, ignore
126
- }
127
- }
128
-
129
- /**
130
- * @param {'log' | 'artifact' | 'keyvalue'} dataType
131
- * @param {*} context
132
- * @returns array of data (any type)
133
- */
134
- #getDataFromFile(dataType, context) {
135
- const dataDirPath = path.join(TESTOMAT_TMP_STORAGE_DIR, dataType);
136
- try {
137
- const filepath = join(dataDirPath, `${dataType}_${context}`);
138
- if (fs.existsSync(filepath)) {
139
- const testDataAsText = fs.readFileSync(filepath, 'utf-8');
140
- if (testDataAsText) debug(`"${dataType}" data for context "${context}":`, testDataAsText);
141
- const testDataArr = testDataAsText?.split(os.EOL) || [];
142
- return testDataArr;
143
- }
144
- // debug(`No ${this.dataType} data for ${context} in <file> storage`);
145
- return [];
146
- } catch (e) {
147
- // there could be no data, ignore
148
- }
149
- return [];
150
- }
151
-
152
- /**
153
- * Puts data to global variable. Unlike the file storage, stores data in array (file storage just append as string).
154
- * @param {'log' | 'artifact' | 'keyvalue'} dataType
155
- * @param {*} data
156
- * @param {*} context
157
- */
158
- #putDataToGlobalVar(dataType, data, context) {
159
- debug('Saving data to global variable for ', context, ':', data);
160
- if (!global.testomatioDataStore) global.testomatioDataStore = {};
161
- if (!global.testomatioDataStore?.[dataType]) global.testomatioDataStore[dataType] = {};
162
-
163
- if (!global.testomatioDataStore?.[dataType][context]) global.testomatioDataStore[dataType][context] = [];
164
- global.testomatioDataStore[dataType][context].push(data);
165
- }
166
-
167
- /**
168
- * Puts data to file. Unlike the global variable storage, stores data as string
169
- * @param {'log' | 'artifact' | 'keyvalue'} dataType
170
- * @param {*} data
171
- * @param {string} context
172
- * @returns
173
- */
174
- #putDataToFile(dataType, data, context) {
175
- const dataDirPath = path.join(TESTOMAT_TMP_STORAGE_DIR, dataType);
176
- if (typeof data !== 'string') data = JSON.stringify(data);
177
- const filename = `${dataType}_${context}`;
178
- const filepath = join(dataDirPath, filename);
179
- if (!fs.existsSync(dataDirPath)) fileSystem.createDir(dataDirPath);
180
- debug(`Saving data to file for context "${context}" to ${filepath}. Data: ${JSON.stringify(data)}`);
181
-
182
- // append new line if file already exists (in this case its definitely includes some data)
183
- if (fs.existsSync(filepath)) {
184
- fs.appendFileSync(filepath, os.EOL + data, 'utf-8');
185
- } else {
186
- fs.writeFileSync(filepath, data, 'utf-8');
187
- }
188
- }
189
- }
190
-
191
- function stringToMD5Hash(str) {
192
- const md5 = crypto.createHash('md5');
193
- md5.update(str);
194
- const hash = md5.digest('hex');
195
-
196
- return hash;
197
- }
198
-
199
- export const dataStorage = DataStorage.getInstance();
200
-
201
- export { stringToMD5Hash };
202
-
203
- // TODO: consider using fs promises instead of writeSync/appendFileSync to
204
- // prevent blocking and improve performance (probably queue usage will be required)
@@ -1,23 +0,0 @@
1
- class Adapter {
2
- constructor(opts) {
3
- this.opts = opts;
4
- }
5
-
6
- getFilePath(t) {
7
- return t.file;
8
- }
9
-
10
- formatTest(t) {
11
- return t;
12
- }
13
-
14
- formatStack(t) {
15
- return t.stack || '';
16
- }
17
-
18
- formatMessage(t) {
19
- return t.message;
20
- }
21
- }
22
-
23
- export default Adapter;
@@ -1,28 +0,0 @@
1
- import path from 'path';
2
- import Adapter from './adapter.js';
3
-
4
- class CSharpAdapter extends Adapter {
5
- formatTest(t) {
6
- const title = t.title.replace(/\(.*?\)/, '').trim();
7
- const example = t.title.match(/\((.*?)\)/);
8
- if (example) t.example = { ...example[1].split(',') };
9
- const suite = t.suite_title.split('.');
10
- t.suite_title = suite.pop();
11
- t.file = namespaceToFileName(t.file);
12
- t.title = title.trim();
13
- return t;
14
- }
15
-
16
- getFilePath(t) {
17
- const fileName = namespaceToFileName(t.file);
18
- return fileName;
19
- }
20
- }
21
-
22
- export default CSharpAdapter;
23
-
24
- function namespaceToFileName(fileName) {
25
- const fileParts = fileName.split('.');
26
- fileParts[fileParts.length - 1] = fileParts[fileParts.length - 1]?.replace(/\$.*/, '');
27
- return `${fileParts.join(path.sep)}.cs`;
28
- }
@@ -1,28 +0,0 @@
1
- import Adapter from './adapter.js';
2
- import JavaScriptAdapter from './javascript.js';
3
- import JavaAdapter from './java.js';
4
- import PythonAdapter from './python.js';
5
- import RubyAdapter from './ruby.js';
6
- import CSharpAdapter from './csharp.js';
7
-
8
- function AdapterFactory(lang, opts) {
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);
26
- }
27
-
28
- export default AdapterFactory;
@@ -1,58 +0,0 @@
1
- import path from 'path';
2
- import Adapter from './adapter.js';
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;
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
- // }
50
- }
51
-
52
- function namespaceToFileName(fileName) {
53
- const fileParts = fileName.split('.');
54
- fileParts[fileParts.length - 1] = fileParts[fileParts.length - 1]?.replace(/\$.*/, '');
55
- return `${fileParts.join(path.sep)}.java`;
56
- }
57
-
58
- export default JavaAdapter;
@@ -1,31 +0,0 @@
1
- import createCallsiteRecord from 'callsite-record';
2
- import path from 'path';
3
- import Adapter from './adapter.js';
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
- // @ts-ignore
16
- if (record && !record.filename.startsWith('http')) {
17
- stack += record.renderSync({
18
- stackFilter: frame =>
19
- frame.fileName?.indexOf(path.sep) > -1 &&
20
- frame.fileName?.indexOf('node_modules') < 0 &&
21
- frame.fileName?.indexOf('internal') < 0,
22
- });
23
- }
24
- return stack;
25
- } catch (err) {
26
- return stack;
27
- }
28
- }
29
- }
30
-
31
- export default JavaScriptAdapter;
@@ -1,42 +0,0 @@
1
- import path from 'path';
2
- import fs from 'fs';
3
- import Adapter from './adapter.js';
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('&#10;')[0];
25
- }
26
- }
27
-
28
- function namespaceToFileName(fileName, opts = {}) {
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;
36
- }
37
- fileParts.pop();
38
- }
39
- return null;
40
- }
41
-
42
- export default PythonAdapter;
@@ -1,10 +0,0 @@
1
- import Adapter from './adapter.js';
2
-
3
- class RubyAdapter extends Adapter {
4
- formatStack(t) {
5
- const stack = super.formatStack(t);
6
- return stack.replace(/\[(.*?:.\d*)\]/g, '\n$1');
7
- }
8
- }
9
-
10
- export default RubyAdapter;
package/src/output.js DELETED
@@ -1,57 +0,0 @@
1
- import { format } from 'util';
2
-
3
- const consoleLog = console.log;
4
- const consoleError = console.error;
5
-
6
- const formatArgs = args => format.apply(format, Array.prototype.slice.call(args));
7
-
8
- class Output {
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
- }
55
- }
56
-
57
- export default Output;