@webex/xunit-with-logs 2.37.0 → 2.37.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/dist/index.js CHANGED
@@ -1,48 +1,38 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
4
-
5
4
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
6
-
7
5
  var _apply = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/apply"));
8
-
9
6
  var _entries = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/entries"));
10
-
11
7
  /*!
12
8
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
13
9
  */
10
+
14
11
  // These'll get cleaned up in the xunit PR; for now, they're just here because
15
12
  // this file attempted to follow the format of the mocha core xunit reporter
16
-
17
13
  /* eslint-disable no-console */
18
-
19
14
  /* eslint-disable no-multi-assign */
20
15
 
21
16
  /**
22
17
  * Module dependencies.
23
18
  */
24
- var util = require('util');
25
19
 
20
+ var util = require('util');
26
21
  var fs = require('fs');
27
-
28
22
  var Base = require('mocha/lib/reporters/base');
29
-
30
23
  var utils = require('mocha/lib/utils');
31
-
32
24
  var escape = utils.escape;
33
-
34
25
  var mkdirp = require('mkdirp');
35
-
36
26
  var path = require('path');
37
-
38
27
  var _require = require('lodash'),
39
- pick = _require.pick;
28
+ pick = _require.pick;
29
+
40
30
  /**
41
31
  * Expose `XUnit`.
42
32
  */
43
33
 
44
-
45
34
  exports = module.exports = XUnit;
35
+
46
36
  /**
47
37
  * Initialize a new `XUnit` reporter.
48
38
  *
@@ -51,22 +41,18 @@ exports = module.exports = XUnit;
51
41
  * @returns {undefined}
52
42
  * @api public
53
43
  */
54
-
55
44
  function XUnit(runner, options) {
56
45
  (0, _apply.default)(Base, this, [runner]);
57
46
  var stats = this.stats;
58
47
  var tests = [];
59
48
  var self = this;
60
-
61
49
  if (options.reporterOptions && options.reporterOptions.output) {
62
50
  if (!fs.createWriteStream) {
63
51
  throw new Error('file output not supported in browser');
64
52
  }
65
-
66
53
  mkdirp.sync(path.dirname(options.reporterOptions.output));
67
54
  self.fileStream = fs.createWriteStream(options.reporterOptions.output);
68
55
  }
69
-
70
56
  runner.on('pending', function (test) {
71
57
  tests.push(test);
72
58
  });
@@ -85,21 +71,17 @@ function XUnit(runner, options) {
85
71
  if (!console[methodName]) {
86
72
  methodName = 'log';
87
73
  }
88
-
89
74
  console[methodName] = function () {
90
75
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
91
76
  args[_key] = arguments[_key];
92
77
  }
93
-
94
78
  (0, _apply.default)(originalMethods[methodName], console, args);
95
79
  var callerInfo = new Error().stack.split('\n')[2].match(/\((.+?):(\d+):\d+/);
96
-
97
80
  if (callerInfo && callerInfo.length >= 2) {
98
81
  var callerFile = path.relative(__dirname, '..', callerInfo[1]);
99
82
  args.unshift("(FILE:".concat(callerFile || 'UNKNOWN', ")"));
100
83
  args.unshift("(LINE:".concat(callerInfo[2] || 'UNKNOWN', ")"));
101
84
  }
102
-
103
85
  if (methodName === 'error') {
104
86
  test.systemErr.push(args);
105
87
  } else {
@@ -132,12 +114,12 @@ function XUnit(runner, options) {
132
114
  self.write('</testsuites>');
133
115
  });
134
116
  }
117
+
135
118
  /**
136
119
  * Inherit from `Base.prototype`.
137
120
  */
138
-
139
-
140
121
  util.inherits(XUnit, Base);
122
+
141
123
  /**
142
124
  * Override done to close the stream (if it's a file).
143
125
  *
@@ -145,7 +127,6 @@ util.inherits(XUnit, Base);
145
127
  * @param {Function} fn
146
128
  * @returns {undefined}
147
129
  */
148
-
149
130
  XUnit.prototype.done = function done(failures, fn) {
150
131
  if (this.fileStream) {
151
132
  this.fileStream.end(function () {
@@ -155,14 +136,13 @@ XUnit.prototype.done = function done(failures, fn) {
155
136
  fn(failures);
156
137
  }
157
138
  };
139
+
158
140
  /**
159
141
  * Write out the given line.
160
142
  *
161
143
  * @param {string} line
162
144
  * @returns {undefined}
163
145
  */
164
-
165
-
166
146
  XUnit.prototype.write = function write(line) {
167
147
  if (this.fileStream) {
168
148
  this.fileStream.write("".concat(line, "\n"));
@@ -170,14 +150,13 @@ XUnit.prototype.write = function write(line) {
170
150
  console.log(line);
171
151
  }
172
152
  };
153
+
173
154
  /**
174
155
  * Output tag for the given `test.`
175
156
  *
176
157
  * @param {Test} test
177
158
  * @returns {undefined}
178
159
  */
179
-
180
-
181
160
  XUnit.prototype.test = function testFn(test) {
182
161
  var attrs = {
183
162
  classname: test.parent.fullTitle(),
@@ -185,21 +164,17 @@ XUnit.prototype.test = function testFn(test) {
185
164
  time: test.duration / 1000 || 0
186
165
  };
187
166
  var systemErr;
188
-
189
167
  if (test.systemErr && test.systemErr.length > 0) {
190
168
  systemErr = tag('system-err', {}, false, cdata(test.systemErr.reduce(reducer, '\n')));
191
169
  } else {
192
170
  systemErr = '';
193
171
  }
194
-
195
172
  var systemOut;
196
-
197
173
  if (test.systemOut && test.systemOut.length > 0) {
198
174
  systemOut = tag('system-out', {}, false, cdata(test.systemOut.reduce(reducer, '\n')));
199
175
  } else {
200
176
  systemOut = '';
201
177
  }
202
-
203
178
  if (test.state === 'failed') {
204
179
  var err = test.err;
205
180
  var failureMessage = tag('failure', {}, false, cdata("".concat(escape(err.message), "\n").concat(err.stack)));
@@ -209,6 +184,7 @@ XUnit.prototype.test = function testFn(test) {
209
184
  } else {
210
185
  this.write(tag('testcase', attrs, true));
211
186
  }
187
+
212
188
  /**
213
189
  * reducer
214
190
  * @param {string} out
@@ -216,14 +192,13 @@ XUnit.prototype.test = function testFn(test) {
216
192
  * @returns {string}
217
193
  * @private
218
194
  */
219
-
220
-
221
195
  function reducer(out, args) {
222
196
  return "".concat(out + args.reduce(function (innerOut, arg) {
223
197
  return "".concat(innerOut + arg, " ");
224
198
  }, ''), "\n");
225
199
  }
226
200
  };
201
+
227
202
  /**
228
203
  * HTML tag helper.
229
204
  *
@@ -233,36 +208,28 @@ XUnit.prototype.test = function testFn(test) {
233
208
  * @param {string} content
234
209
  * @returns {string}
235
210
  */
236
-
237
-
238
211
  function tag(name, attrs, close, content) {
239
212
  var end = close ? '/>' : '>';
240
213
  var pairs = [];
241
214
  var innerTag;
242
-
243
215
  for (var _i = 0, _Object$entries = (0, _entries.default)(attrs); _i < _Object$entries.length; _i++) {
244
216
  var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
245
- key = _Object$entries$_i[0],
246
- value = _Object$entries$_i[1];
247
-
217
+ key = _Object$entries$_i[0],
218
+ value = _Object$entries$_i[1];
248
219
  pairs.push("".concat(key, "=\"").concat(escape(value), "\""));
249
220
  }
250
-
251
221
  innerTag = "<".concat(name).concat(pairs.length ? " ".concat(pairs.join(' ')) : '').concat(end);
252
-
253
222
  if (content) {
254
223
  innerTag += "".concat(content, "</").concat(name).concat(end);
255
224
  }
256
-
257
225
  return innerTag;
258
226
  }
227
+
259
228
  /**
260
229
  * Return cdata escaped CDATA `str`.
261
230
  * @param {string} str
262
231
  * @returns {string}
263
232
  */
264
-
265
-
266
233
  function cdata(str) {
267
234
  return "<![CDATA[".concat(escape(str), "]]>");
268
235
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["util","require","fs","Base","utils","escape","mkdirp","path","pick","exports","module","XUnit","runner","options","stats","tests","self","reporterOptions","output","createWriteStream","Error","sync","dirname","fileStream","on","test","push","logMethodNames","originalMethods","console","systemErr","systemOut","forEach","methodName","args","callerInfo","stack","split","match","length","callerFile","relative","__dirname","unshift","toUpperCase","write","tag","name","failures","errors","skipped","passes","timestamp","Date","toUTCString","time","duration","t","inherits","prototype","done","fn","end","line","log","testFn","attrs","classname","parent","fullTitle","title","cdata","reduce","reducer","state","err","failureMessage","message","pending","out","innerOut","arg","close","content","pairs","innerTag","key","value","join","str"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n// These'll get cleaned up in the xunit PR; for now, they're just here because\n// this file attempted to follow the format of the mocha core xunit reporter\n/* eslint-disable no-console */\n/* eslint-disable no-multi-assign */\n\n/**\n * Module dependencies.\n */\n\nconst util = require('util');\nconst fs = require('fs');\n\nconst Base = require('mocha/lib/reporters/base');\nconst utils = require('mocha/lib/utils');\n\nconst {escape} = utils;\nconst mkdirp = require('mkdirp');\n\nconst path = require('path');\n\nconst {pick} = require('lodash');\n\n/**\n * Expose `XUnit`.\n */\n\nexports = module.exports = XUnit;\n\n/**\n * Initialize a new `XUnit` reporter.\n *\n * @param {Runner} runner\n * @param {Object} options\n * @returns {undefined}\n * @api public\n */\nfunction XUnit(runner, options) {\n Reflect.apply(Base, this, [runner]);\n const {stats} = this;\n const tests = [];\n const self = this;\n\n if (options.reporterOptions && options.reporterOptions.output) {\n if (!fs.createWriteStream) {\n throw new Error('file output not supported in browser');\n }\n mkdirp.sync(path.dirname(options.reporterOptions.output));\n self.fileStream = fs.createWriteStream(options.reporterOptions.output);\n }\n\n runner.on('pending', (test) => {\n tests.push(test);\n });\n\n runner.on('pass', (test) => {\n tests.push(test);\n });\n\n runner.on('fail', (test) => {\n tests.push(test);\n });\n\n const logMethodNames = ['error', 'warn', 'log', 'info', 'debug', 'trace'];\n const originalMethods = pick(console, logMethodNames);\n\n runner.on('test', (test) => {\n test.systemErr = [];\n test.systemOut = [];\n\n logMethodNames.forEach((methodName) => {\n if (!console[methodName]) {\n methodName = 'log';\n }\n\n console[methodName] = (...args) => {\n Reflect.apply(originalMethods[methodName], console, args);\n\n const callerInfo = (new Error())\n .stack\n .split('\\n')[2]\n .match(/\\((.+?):(\\d+):\\d+/);\n\n if (callerInfo && callerInfo.length >= 2) {\n const callerFile = path.relative(__dirname, '..', callerInfo[1]);\n\n args.unshift(`(FILE:${callerFile || 'UNKNOWN'})`);\n args.unshift(`(LINE:${callerInfo[2] || 'UNKNOWN'})`);\n }\n\n if (methodName === 'error') {\n test.systemErr.push(args);\n }\n else {\n args.unshift(`${methodName.toUpperCase()}:`);\n\n test.systemOut.push(args);\n }\n };\n });\n });\n\n runner.on('test end', () => {\n logMethodNames.forEach((methodName) => {\n console[methodName] = originalMethods[methodName];\n });\n });\n\n runner.on('end', () => {\n self.write('<testsuites>');\n self.write(tag('testsuite', {\n name: 'Mocha Tests',\n tests: stats.tests,\n failures: stats.failures,\n errors: stats.failures,\n skipped: stats.tests - stats.failures - stats.passes,\n timestamp: (new Date()).toUTCString(),\n time: stats.duration / 1000 || 0\n }, false));\n\n tests.forEach((t) => {\n self.test(t);\n });\n\n self.write('</testsuite>');\n self.write('</testsuites>');\n });\n}\n\n/**\n * Inherit from `Base.prototype`.\n */\nutil.inherits(XUnit, Base);\n\n/**\n * Override done to close the stream (if it's a file).\n *\n * @param {Array} failures\n * @param {Function} fn\n * @returns {undefined}\n */\nXUnit.prototype.done = function done(failures, fn) {\n if (this.fileStream) {\n this.fileStream.end(() => {\n fn(failures);\n });\n }\n else {\n fn(failures);\n }\n};\n\n/**\n * Write out the given line.\n *\n * @param {string} line\n * @returns {undefined}\n */\nXUnit.prototype.write = function write(line) {\n if (this.fileStream) {\n this.fileStream.write(`${line}\\n`);\n }\n else {\n console.log(line);\n }\n};\n\n/**\n * Output tag for the given `test.`\n *\n * @param {Test} test\n * @returns {undefined}\n */\nXUnit.prototype.test = function testFn(test) {\n const attrs = {\n classname: test.parent.fullTitle(),\n name: test.title,\n time: test.duration / 1000 || 0\n };\n\n let systemErr;\n\n if (test.systemErr && test.systemErr.length > 0) {\n systemErr = tag('system-err', {}, false, cdata(test.systemErr.reduce(reducer, '\\n')));\n }\n else {\n systemErr = '';\n }\n\n let systemOut;\n\n if (test.systemOut && test.systemOut.length > 0) {\n systemOut = tag('system-out', {}, false, cdata(test.systemOut.reduce(reducer, '\\n')));\n }\n else {\n systemOut = '';\n }\n\n if (test.state === 'failed') {\n const {err} = test;\n const failureMessage = tag('failure', {}, false, cdata(`${escape(err.message)}\\n${err.stack}`));\n\n this.write(tag('testcase', attrs, false, failureMessage + systemOut + systemErr));\n }\n else if (test.pending) {\n this.write(tag('testcase', attrs, false, tag('skipped', {}, true)));\n }\n else {\n this.write(tag('testcase', attrs, true));\n }\n\n /**\n * reducer\n * @param {string} out\n * @param {Array<mixed>} args\n * @returns {string}\n * @private\n */\n function reducer(out, args) {\n return `${out + args.reduce((innerOut, arg) => `${innerOut + arg} `, '')}\\n`;\n }\n};\n\n/**\n * HTML tag helper.\n *\n * @param {string} name\n * @param {Object} attrs\n * @param {boolean} close\n * @param {string} content\n * @returns {string}\n */\nfunction tag(name, attrs, close, content) {\n const end = close ? '/>' : '>';\n const pairs = [];\n let innerTag;\n\n for (const [key, value] of Object.entries(attrs)) {\n pairs.push(`${key}=\"${escape(value)}\"`);\n }\n\n innerTag = `<${name}${pairs.length ? ` ${pairs.join(' ')}` : ''}${end}`;\n if (content) {\n innerTag += `${content}</${name}${end}`;\n }\n\n return innerTag;\n}\n\n/**\n * Return cdata escaped CDATA `str`.\n * @param {string} str\n * @returns {string}\n */\nfunction cdata(str) {\n return `<![CDATA[${escape(str)}]]>`;\n}\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AAEA;AACA;;AACA;;AACA;;AAEA;AACA;AACA;AAEA,IAAMA,IAAI,GAAGC,OAAO,CAAC,MAAD,CAApB;;AACA,IAAMC,EAAE,GAAGD,OAAO,CAAC,IAAD,CAAlB;;AAEA,IAAME,IAAI,GAAGF,OAAO,CAAC,0BAAD,CAApB;;AACA,IAAMG,KAAK,GAAGH,OAAO,CAAC,iBAAD,CAArB;;AAEA,IAAOI,MAAP,GAAiBD,KAAjB,CAAOC,MAAP;;AACA,IAAMC,MAAM,GAAGL,OAAO,CAAC,QAAD,CAAtB;;AAEA,IAAMM,IAAI,GAAGN,OAAO,CAAC,MAAD,CAApB;;AAEA,eAAeA,OAAO,CAAC,QAAD,CAAtB;AAAA,IAAOO,IAAP,YAAOA,IAAP;AAEA;AACA;AACA;;;AAEA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G,EAAd;EACA,IAAIC,QAAJ;;EAEA,mCAA2B,sBAAenB,KAAf,CAA3B,qCAAkD;IAA7C;IAAA,IAAOoB,GAAP;IAAA,IAAYC,KAAZ;;IACHH,KAAK,CAAC1D,IAAN,WAAc4D,GAAd,gBAAsBjF,MAAM,CAACkF,KAAD,CAA5B;EACD;;EAEDF,QAAQ,cAAOtC,IAAP,SAAcqC,KAAK,CAAC7C,MAAN,cAAmB6C,KAAK,CAACI,IAAN,CAAW,GAAX,CAAnB,IAAuC,EAArD,SAA0D1B,GAA1D,CAAR;;EACA,IAAIqB,OAAJ,EAAa;IACXE,QAAQ,cAAOF,OAAP,eAAmBpC,IAAnB,SAA0Be,GAA1B,CAAR;EACD;;EAED,OAAOuB,QAAP;AACD;AAED;AACA;AACA;AACA;AACA;;;AACA,SAASd,KAAT,CAAekB,GAAf,EAAoB;EAClB,0BAAmBpF,MAAM,CAACoF,GAAD,CAAzB;AACD"}
1
+ {"version":3,"names":["util","require","fs","Base","utils","escape","mkdirp","path","pick","exports","module","XUnit","runner","options","stats","tests","self","reporterOptions","output","createWriteStream","Error","sync","dirname","fileStream","on","test","push","logMethodNames","originalMethods","console","systemErr","systemOut","forEach","methodName","args","callerInfo","stack","split","match","length","callerFile","relative","__dirname","unshift","toUpperCase","write","tag","name","failures","errors","skipped","passes","timestamp","Date","toUTCString","time","duration","t","inherits","prototype","done","fn","end","line","log","testFn","attrs","classname","parent","fullTitle","title","cdata","reduce","reducer","state","err","failureMessage","message","pending","out","innerOut","arg","close","content","pairs","innerTag","key","value","join","str"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n// These'll get cleaned up in the xunit PR; for now, they're just here because\n// this file attempted to follow the format of the mocha core xunit reporter\n/* eslint-disable no-console */\n/* eslint-disable no-multi-assign */\n\n/**\n * Module dependencies.\n */\n\nconst util = require('util');\nconst fs = require('fs');\n\nconst Base = require('mocha/lib/reporters/base');\nconst utils = require('mocha/lib/utils');\n\nconst {escape} = utils;\nconst mkdirp = require('mkdirp');\n\nconst path = require('path');\n\nconst {pick} = require('lodash');\n\n/**\n * Expose `XUnit`.\n */\n\nexports = module.exports = XUnit;\n\n/**\n * Initialize a new `XUnit` reporter.\n *\n * @param {Runner} runner\n * @param {Object} options\n * @returns {undefined}\n * @api public\n */\nfunction XUnit(runner, options) {\n Reflect.apply(Base, this, [runner]);\n const {stats} = this;\n const tests = [];\n const self = this;\n\n if (options.reporterOptions && options.reporterOptions.output) {\n if (!fs.createWriteStream) {\n throw new Error('file output not supported in browser');\n }\n mkdirp.sync(path.dirname(options.reporterOptions.output));\n self.fileStream = fs.createWriteStream(options.reporterOptions.output);\n }\n\n runner.on('pending', (test) => {\n tests.push(test);\n });\n\n runner.on('pass', (test) => {\n tests.push(test);\n });\n\n runner.on('fail', (test) => {\n tests.push(test);\n });\n\n const logMethodNames = ['error', 'warn', 'log', 'info', 'debug', 'trace'];\n const originalMethods = pick(console, logMethodNames);\n\n runner.on('test', (test) => {\n test.systemErr = [];\n test.systemOut = [];\n\n logMethodNames.forEach((methodName) => {\n if (!console[methodName]) {\n methodName = 'log';\n }\n\n console[methodName] = (...args) => {\n Reflect.apply(originalMethods[methodName], console, args);\n\n const callerInfo = new Error().stack.split('\\n')[2].match(/\\((.+?):(\\d+):\\d+/);\n\n if (callerInfo && callerInfo.length >= 2) {\n const callerFile = path.relative(__dirname, '..', callerInfo[1]);\n\n args.unshift(`(FILE:${callerFile || 'UNKNOWN'})`);\n args.unshift(`(LINE:${callerInfo[2] || 'UNKNOWN'})`);\n }\n\n if (methodName === 'error') {\n test.systemErr.push(args);\n } else {\n args.unshift(`${methodName.toUpperCase()}:`);\n\n test.systemOut.push(args);\n }\n };\n });\n });\n\n runner.on('test end', () => {\n logMethodNames.forEach((methodName) => {\n console[methodName] = originalMethods[methodName];\n });\n });\n\n runner.on('end', () => {\n self.write('<testsuites>');\n self.write(\n tag(\n 'testsuite',\n {\n name: 'Mocha Tests',\n tests: stats.tests,\n failures: stats.failures,\n errors: stats.failures,\n skipped: stats.tests - stats.failures - stats.passes,\n timestamp: new Date().toUTCString(),\n time: stats.duration / 1000 || 0,\n },\n false\n )\n );\n\n tests.forEach((t) => {\n self.test(t);\n });\n\n self.write('</testsuite>');\n self.write('</testsuites>');\n });\n}\n\n/**\n * Inherit from `Base.prototype`.\n */\nutil.inherits(XUnit, Base);\n\n/**\n * Override done to close the stream (if it's a file).\n *\n * @param {Array} failures\n * @param {Function} fn\n * @returns {undefined}\n */\nXUnit.prototype.done = function done(failures, fn) {\n if (this.fileStream) {\n this.fileStream.end(() => {\n fn(failures);\n });\n } else {\n fn(failures);\n }\n};\n\n/**\n * Write out the given line.\n *\n * @param {string} line\n * @returns {undefined}\n */\nXUnit.prototype.write = function write(line) {\n if (this.fileStream) {\n this.fileStream.write(`${line}\\n`);\n } else {\n console.log(line);\n }\n};\n\n/**\n * Output tag for the given `test.`\n *\n * @param {Test} test\n * @returns {undefined}\n */\nXUnit.prototype.test = function testFn(test) {\n const attrs = {\n classname: test.parent.fullTitle(),\n name: test.title,\n time: test.duration / 1000 || 0,\n };\n\n let systemErr;\n\n if (test.systemErr && test.systemErr.length > 0) {\n systemErr = tag('system-err', {}, false, cdata(test.systemErr.reduce(reducer, '\\n')));\n } else {\n systemErr = '';\n }\n\n let systemOut;\n\n if (test.systemOut && test.systemOut.length > 0) {\n systemOut = tag('system-out', {}, false, cdata(test.systemOut.reduce(reducer, '\\n')));\n } else {\n systemOut = '';\n }\n\n if (test.state === 'failed') {\n const {err} = test;\n const failureMessage = tag('failure', {}, false, cdata(`${escape(err.message)}\\n${err.stack}`));\n\n this.write(tag('testcase', attrs, false, failureMessage + systemOut + systemErr));\n } else if (test.pending) {\n this.write(tag('testcase', attrs, false, tag('skipped', {}, true)));\n } else {\n this.write(tag('testcase', attrs, true));\n }\n\n /**\n * reducer\n * @param {string} out\n * @param {Array<mixed>} args\n * @returns {string}\n * @private\n */\n function reducer(out, args) {\n return `${out + args.reduce((innerOut, arg) => `${innerOut + arg} `, '')}\\n`;\n }\n};\n\n/**\n * HTML tag helper.\n *\n * @param {string} name\n * @param {Object} attrs\n * @param {boolean} close\n * @param {string} content\n * @returns {string}\n */\nfunction tag(name, attrs, close, content) {\n const end = close ? '/>' : '>';\n const pairs = [];\n let innerTag;\n\n for (const [key, value] of Object.entries(attrs)) {\n pairs.push(`${key}=\"${escape(value)}\"`);\n }\n\n innerTag = `<${name}${pairs.length ? ` ${pairs.join(' ')}` : ''}${end}`;\n if (content) {\n innerTag += `${content}</${name}${end}`;\n }\n\n return innerTag;\n}\n\n/**\n * Return cdata escaped CDATA `str`.\n * @param {string} str\n * @returns {string}\n */\nfunction cdata(str) {\n return `<![CDATA[${escape(str)}]]>`;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,IAAMA,IAAI,GAAGC,OAAO,CAAC,MAAM,CAAC;AAC5B,IAAMC,EAAE,GAAGD,OAAO,CAAC,IAAI,CAAC;AAExB,IAAME,IAAI,GAAGF,OAAO,CAAC,0BAA0B,CAAC;AAChD,IAAMG,KAAK,GAAGH,OAAO,CAAC,iBAAiB,CAAC;AAExC,IAAOI,MAAM,GAAID,KAAK,CAAfC,MAAM;AACb,IAAMC,MAAM,GAAGL,OAAO,CAAC,QAAQ,CAAC;AAEhC,IAAMM,IAAI,GAAGN,OAAO,CAAC,MAAM,CAAC;AAE5B,eAAeA,OAAO,CAAC,QAAQ,CAAC;EAAzBO,IAAI,YAAJA,IAAI;;AAEX;AACA;AACA;;AAEAC,OAAO,GAAGC,MAAM,CAACD,OAAO,GAAGE,KAAK;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,KAAK,CAACC,MAAM,EAAEC,OAAO,EAAE;EAC9B,oBAAcV,IAAI,EAAE,IAAI,EAAE,CAACS,MAAM,CAAC,CAAC;EACnC,IAAOE,KAAK,GAAI,IAAI,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F,QAAQ,cAAOtC,IAAI,SAAGqC,KAAK,CAAC7C,MAAM,cAAO6C,KAAK,CAACI,IAAI,CAAC,GAAG,CAAC,IAAK,EAAE,SAAG1B,GAAG,CAAE;EACvE,IAAIqB,OAAO,EAAE;IACXE,QAAQ,cAAOF,OAAO,eAAKpC,IAAI,SAAGe,GAAG,CAAE;EACzC;EAEA,OAAOuB,QAAQ;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASd,KAAK,CAACkB,GAAG,EAAE;EAClB,0BAAmBpF,MAAM,CAACoF,GAAG,CAAC;AAChC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/xunit-with-logs",
3
- "version": "2.37.0",
3
+ "version": "2.37.2",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
package/src/index.js CHANGED
@@ -79,10 +79,7 @@ function XUnit(runner, options) {
79
79
  console[methodName] = (...args) => {
80
80
  Reflect.apply(originalMethods[methodName], console, args);
81
81
 
82
- const callerInfo = (new Error())
83
- .stack
84
- .split('\n')[2]
85
- .match(/\((.+?):(\d+):\d+/);
82
+ const callerInfo = new Error().stack.split('\n')[2].match(/\((.+?):(\d+):\d+/);
86
83
 
87
84
  if (callerInfo && callerInfo.length >= 2) {
88
85
  const callerFile = path.relative(__dirname, '..', callerInfo[1]);
@@ -93,8 +90,7 @@ function XUnit(runner, options) {
93
90
 
94
91
  if (methodName === 'error') {
95
92
  test.systemErr.push(args);
96
- }
97
- else {
93
+ } else {
98
94
  args.unshift(`${methodName.toUpperCase()}:`);
99
95
 
100
96
  test.systemOut.push(args);
@@ -111,15 +107,21 @@ function XUnit(runner, options) {
111
107
 
112
108
  runner.on('end', () => {
113
109
  self.write('<testsuites>');
114
- self.write(tag('testsuite', {
115
- name: 'Mocha Tests',
116
- tests: stats.tests,
117
- failures: stats.failures,
118
- errors: stats.failures,
119
- skipped: stats.tests - stats.failures - stats.passes,
120
- timestamp: (new Date()).toUTCString(),
121
- time: stats.duration / 1000 || 0
122
- }, false));
110
+ self.write(
111
+ tag(
112
+ 'testsuite',
113
+ {
114
+ name: 'Mocha Tests',
115
+ tests: stats.tests,
116
+ failures: stats.failures,
117
+ errors: stats.failures,
118
+ skipped: stats.tests - stats.failures - stats.passes,
119
+ timestamp: new Date().toUTCString(),
120
+ time: stats.duration / 1000 || 0,
121
+ },
122
+ false
123
+ )
124
+ );
123
125
 
124
126
  tests.forEach((t) => {
125
127
  self.test(t);
@@ -147,8 +149,7 @@ XUnit.prototype.done = function done(failures, fn) {
147
149
  this.fileStream.end(() => {
148
150
  fn(failures);
149
151
  });
150
- }
151
- else {
152
+ } else {
152
153
  fn(failures);
153
154
  }
154
155
  };
@@ -162,8 +163,7 @@ XUnit.prototype.done = function done(failures, fn) {
162
163
  XUnit.prototype.write = function write(line) {
163
164
  if (this.fileStream) {
164
165
  this.fileStream.write(`${line}\n`);
165
- }
166
- else {
166
+ } else {
167
167
  console.log(line);
168
168
  }
169
169
  };
@@ -178,15 +178,14 @@ XUnit.prototype.test = function testFn(test) {
178
178
  const attrs = {
179
179
  classname: test.parent.fullTitle(),
180
180
  name: test.title,
181
- time: test.duration / 1000 || 0
181
+ time: test.duration / 1000 || 0,
182
182
  };
183
183
 
184
184
  let systemErr;
185
185
 
186
186
  if (test.systemErr && test.systemErr.length > 0) {
187
187
  systemErr = tag('system-err', {}, false, cdata(test.systemErr.reduce(reducer, '\n')));
188
- }
189
- else {
188
+ } else {
190
189
  systemErr = '';
191
190
  }
192
191
 
@@ -194,8 +193,7 @@ XUnit.prototype.test = function testFn(test) {
194
193
 
195
194
  if (test.systemOut && test.systemOut.length > 0) {
196
195
  systemOut = tag('system-out', {}, false, cdata(test.systemOut.reduce(reducer, '\n')));
197
- }
198
- else {
196
+ } else {
199
197
  systemOut = '';
200
198
  }
201
199
 
@@ -204,11 +202,9 @@ XUnit.prototype.test = function testFn(test) {
204
202
  const failureMessage = tag('failure', {}, false, cdata(`${escape(err.message)}\n${err.stack}`));
205
203
 
206
204
  this.write(tag('testcase', attrs, false, failureMessage + systemOut + systemErr));
207
- }
208
- else if (test.pending) {
205
+ } else if (test.pending) {
209
206
  this.write(tag('testcase', attrs, false, tag('skipped', {}, true)));
210
- }
211
- else {
207
+ } else {
212
208
  this.write(tag('testcase', attrs, true));
213
209
  }
214
210