testem 3.10.1 → 3.12.0

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.
@@ -3,7 +3,7 @@
3
3
  var XmlDom = require('@xmldom/xmldom');
4
4
  var indent = require('../utils/strutils').indent;
5
5
 
6
- class XUnitReporter {
6
+ module.exports = class XUnitReporter {
7
7
  constructor(silent, out, config) {
8
8
  this.out = out || process.stdout;
9
9
  this.excludeStackTraces = config.get('xunit_exclude_stack');
@@ -13,6 +13,7 @@ class XUnitReporter {
13
13
  this.total = 0;
14
14
  this.pass = 0;
15
15
  this.skipped = 0;
16
+ this.todo = 0;
16
17
  this.results = [];
17
18
  this.startTime = new Date();
18
19
  this.endTime = null;
@@ -23,12 +24,15 @@ class XUnitReporter {
23
24
  launcher: prefix,
24
25
  result: data
25
26
  });
26
- this.display(prefix, data);
27
+ this.display();
27
28
  this.total++;
29
+
28
30
  if (data.skipped) {
29
31
  this.skipped++;
30
- } else if (data.passed) {
32
+ } else if (data.passed && !data.todo) {
31
33
  this.pass++;
34
+ } else if (!data.passed && data.todo) {
35
+ this.todo++;
32
36
  }
33
37
  }
34
38
 
@@ -46,11 +50,12 @@ class XUnitReporter {
46
50
 
47
51
  var rootNode = doc.documentElement;
48
52
  rootNode.setAttribute('name', 'Testem Tests');
49
- rootNode.setAttribute('tests', this.total);
50
- rootNode.setAttribute('skipped', this.skipped);
51
- rootNode.setAttribute('failures', this.failures());
52
- rootNode.setAttribute('timestamp', new Date());
53
- rootNode.setAttribute('time', this.duration());
53
+ rootNode.setAttribute('tests', `${this.total}`);
54
+ rootNode.setAttribute('skipped', `${this.skipped}`);
55
+ rootNode.setAttribute('todo', `${this.todo}`);
56
+ rootNode.setAttribute('failures', `${this.failures()}`);
57
+ rootNode.setAttribute('timestamp', new Date().toString());
58
+ rootNode.setAttribute('time', `${this.duration() }`);
54
59
 
55
60
  for (var i = 0, len = this.results.length; i < len; i++) {
56
61
  var testcaseNode = this.getTestResultNode(doc, this.results[i]);
@@ -107,6 +112,9 @@ class XUnitReporter {
107
112
  } else if (result.skipped) {
108
113
  var skippedNode = document.createElement('skipped');
109
114
  resultNode.appendChild(skippedNode);
115
+ } else if (result.todo) {
116
+ var todoNode = document.createElement('todo');
117
+ resultNode.appendChild(todoNode);
110
118
  } else if (!result.passed) {
111
119
  var failureNode = document.createElement('failure');
112
120
  resultNode.appendChild(failureNode);
@@ -116,11 +124,14 @@ class XUnitReporter {
116
124
  }
117
125
 
118
126
  failures() {
119
- return this.total - this.pass - this.skipped;
127
+ return this.total - this.pass - this.skipped - this.todo;
120
128
  }
121
129
 
122
130
  duration() {
123
- return this._durationFromMs(this.endTime - this.startTime);
131
+ const endTime = this.endTime ? this.endTime.getTime() : 0;
132
+ const startTime = this.startTime.getTime();
133
+
134
+ return this._durationFromMs(endTime - startTime);
124
135
  }
125
136
 
126
137
  _durationFromMs(ms) {
@@ -132,6 +143,4 @@ class XUnitReporter {
132
143
  return 0;
133
144
  }
134
145
  }
135
- }
136
-
137
- module.exports = XUnitReporter;
146
+ };
@@ -217,10 +217,19 @@ class Server extends EventEmitter {
217
217
  this.proxy = new httpProxy.createProxyServer({changeOrigin: true});
218
218
 
219
219
  this.proxy.on('error', (err, req, res) => {
220
- res.status(500).json(err);
220
+ res && res.status && res.status(500).json(err);
221
221
  });
222
222
 
223
- Object.keys(proxies).forEach(url => {
223
+ Object.keys(proxies).forEach((url) => {
224
+ if (proxies[url].ws === true) {
225
+ // set up proxy for WebSocket
226
+ this.server.on('upgrade', (req, socket, head) => {
227
+ if (req.url.startsWith(url)) {
228
+ this.proxy.ws(req, socket, head, proxies[url]);
229
+ }
230
+ });
231
+ return;
232
+ }
224
233
  app.all(`${url}*`, (req, res, next) => {
225
234
  var opts = proxies[url];
226
235
  if (this.shouldProxy(req, opts)) {
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "unittest",
8
8
  "browser"
9
9
  ],
10
- "version": "3.10.1",
10
+ "version": "3.12.0",
11
11
  "author": "Toby Ho <airportyh@gmail.com>",
12
12
  "repository": {
13
13
  "type": "git",
@@ -39,13 +39,13 @@
39
39
  "lodash.clonedeep": "^4.4.1",
40
40
  "lodash.find": "^4.5.1",
41
41
  "lodash.uniqby": "^4.7.0",
42
- "mkdirp": "^1.0.4",
42
+ "mkdirp": "^3.0.1",
43
43
  "mustache": "^4.2.0",
44
44
  "node-notifier": "^10.0.0",
45
45
  "npmlog": "^6.0.0",
46
46
  "printf": "^0.6.1",
47
47
  "rimraf": "^3.0.2",
48
- "socket.io": "^4.1.2",
48
+ "socket.io": "^4.5.4",
49
49
  "spawn-args": "^0.2.0",
50
50
  "styled_string": "0.0.1",
51
51
  "tap-parser": "^7.0.0",