testem 3.11.0 → 3.13.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.
@@ -138,6 +138,8 @@ class Server extends EventEmitter {
138
138
 
139
139
  this.configureProxy(app);
140
140
 
141
+ app.use('/testem', express.static(`${__dirname}/../../public/testem`));
142
+
141
143
  app.get('/', (req, res) => {
142
144
  res.redirect(`/${String(Math.floor(Math.random() * 10000))}`);
143
145
  });
@@ -177,7 +179,6 @@ class Server extends EventEmitter {
177
179
  }
178
180
  next();
179
181
  });
180
- app.use('/testem', express.static(`${__dirname}/../../public/testem`));
181
182
  }
182
183
 
183
184
  injectMiddleware(app) {
@@ -217,10 +218,19 @@ class Server extends EventEmitter {
217
218
  this.proxy = new httpProxy.createProxyServer({changeOrigin: true});
218
219
 
219
220
  this.proxy.on('error', (err, req, res) => {
220
- res.status(500).json(err);
221
+ res && res.status && res.status(500).json(err);
221
222
  });
222
223
 
223
- Object.keys(proxies).forEach(url => {
224
+ Object.keys(proxies).forEach((url) => {
225
+ if (proxies[url].ws === true) {
226
+ // set up proxy for WebSocket
227
+ this.server.on('upgrade', (req, socket, head) => {
228
+ if (req.url.startsWith(url)) {
229
+ this.proxy.ws(req, socket, head, proxies[url]);
230
+ }
231
+ });
232
+ return;
233
+ }
224
234
  app.all(`${url}*`, (req, res, next) => {
225
235
  var opts = proxies[url];
226
236
  if (this.shouldProxy(req, opts)) {
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "unittest",
8
8
  "browser"
9
9
  ],
10
- "version": "3.11.0",
10
+ "version": "3.13.0",
11
11
  "author": "Toby Ho <airportyh@gmail.com>",
12
12
  "repository": {
13
13
  "type": "git",
@@ -45,7 +45,7 @@
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",