From 7bb45ab0aef15c8dcf27969ad1d4982891ec24ba Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Mon, 11 Jul 2016 13:43:34 +0100 Subject: [PATCH] options fix.. remove redundant tests --- lib/local-web-server.js | 7 +- package.json | 2 +- test/compress/big-file.txt | 195 ---------------------------------------- test/compress/compress.js | 22 ----- test/forbid/forbid.js | 21 ----- test/forbid/one.html | 1 - test/forbid/two.php | 1 - test/log/log.js | 25 ------ test/mime/mime.js | 22 ----- test/mime/something.php | 1 - test/mock/mock.js | 150 ------------------------------- test/mock/one.html | 1 - test/proxy/file.txt | 1 - test/proxy/one.html | 1 - test/proxy/rewrite-proxy.js | 73 --------------- test/rewrite/one.html | 1 - test/rewrite/rewrite.js | 19 ---- test/serve-index/serve-index.js | 18 ---- test/spa/one.txt | 1 - test/spa/spa.js | 28 ------ test/spa/two.txt | 1 - test/static/file.txt | 1 - test/static/static.js | 18 ---- test/test.js | 22 ++--- 24 files changed, 18 insertions(+), 614 deletions(-) delete mode 100644 test/compress/big-file.txt delete mode 100644 test/compress/compress.js delete mode 100644 test/forbid/forbid.js delete mode 100644 test/forbid/one.html delete mode 100644 test/forbid/two.php delete mode 100644 test/log/log.js delete mode 100644 test/mime/mime.js delete mode 100644 test/mime/something.php delete mode 100644 test/mock/mock.js delete mode 100644 test/mock/one.html delete mode 100644 test/proxy/file.txt delete mode 100644 test/proxy/one.html delete mode 100644 test/proxy/rewrite-proxy.js delete mode 100644 test/rewrite/one.html delete mode 100644 test/rewrite/rewrite.js delete mode 100644 test/serve-index/serve-index.js delete mode 100644 test/spa/one.txt delete mode 100644 test/spa/spa.js delete mode 100644 test/spa/two.txt delete mode 100644 test/static/file.txt delete mode 100644 test/static/static.js diff --git a/lib/local-web-server.js b/lib/local-web-server.js index bbc60da..8d4ee06 100644 --- a/lib/local-web-server.js +++ b/lib/local-web-server.js @@ -95,9 +95,11 @@ class LocalWebServer { } /* combine in stored config */ - options = Object.assign({ port: 8000 }, initOptions, stored, options.server, options.middleware, options.misc) + options = Object.assign({ port: 8000 }, initOptions, stored || {}, options.server, options.middleware, options.misc) this.options = options + // console.log(initOptions, stored, options) + if (options.verbose) { // debug.setLevel(1) } @@ -176,6 +178,7 @@ class LocalWebServer { listen () { const options = this.options const server = this._server = this.getServer() + // console.log(options) return new Promise((resolve, reject) => { server.listen(options.port, () => { onServerUp(options.port, options['static.root'], server.isHttps) @@ -254,7 +257,7 @@ function loadStack (modulePath) { } function isModule (module) { - return module.prototype.middleware || module.prototype.stack + return module.prototype && (module.prototype.middleware || module.prototype.stack) } module.exports = LocalWebServer diff --git a/package.json b/package.json index 4669e6b..75e51a1 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "bin", "lib", "ssl" ], "scripts": { - "test": "tape test/*/*.js", + "test": "tape test/*.js", "docs": "jsdoc2md -t jsdoc2md/api.hbs -p list lib/*.js > doc/api.md; echo", "cover": "istanbul cover ./node_modules/.bin/tape test/*.js && cat coverage/lcov.info | coveralls && rm -rf coverage; echo" }, diff --git a/test/compress/big-file.txt b/test/compress/big-file.txt deleted file mode 100644 index e837549..0000000 --- a/test/compress/big-file.txt +++ /dev/null @@ -1,195 +0,0 @@ -[![view on npm](http://img.shields.io/npm/v/local-web-server.svg)](https://www.npmjs.org/package/local-web-server) -[![npm module downloads per month](http://img.shields.io/npm/dm/local-web-server.svg)](https://www.npmjs.org/package/local-web-server) -[![Dependency Status](https://david-dm.org/75lb/local-web-server.svg)](https://david-dm.org/75lb/local-web-server) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard) - -# local-web-server -Fires up a simple, CORS-enabled, static web server on a given port. Use for local web development or file sharing (directory browsing enabled). - -![local-web-server](http://75lb.github.io/local-web-server/ws.gif) - -## Install -Ensure [node.js](http://nodejs.org) is installed first. Linux/Mac users may need to run the following commands with `sudo`. - -### Globally -```sh -$ npm install -g local-web-server -``` - -### Bundled with your project -```sh -$ npm install local-web-server --save-dev -``` - -Then add an `start` script to your `package.json` (the standard npm approach): -```json -{ - "name": "my-web-app", - "version": "1.0.0", - "scripts": { - "start": "ws" - } -} -``` -This simplifies a rather specific-looking instruction set like: - -```sh -$ npm install -$ npm install -g local-web-server -$ ws -``` - -to the following, server implementation and launch details abstracted away: -```sh -$ npm install -$ npm start -``` - -## Usage -``` -Usage -$ ws -$ ws --config -$ ws --help - -Server --p, --port Web server port --f, --log.format If a format is supplied an access log is written to stdout. If not, a statistics view is displayed. Use a - preset ('none', 'dev','combined', 'short', 'tiny' or 'logstalgia') or supply a custom format (e.g. ':method -> - :url'). --d, --directory Root directory, defaults to the current directory --c, --compress Enable gzip compression, reduces bandwidth. --r, --refresh-rate Statistics view refresh rate in ms. Defaults to 500. - -Misc --h, --help Print these usage instructions ---config Print the stored config -``` - -From the folder you wish to serve, run: -```sh -$ ws -serving at http://localhost:8000 -``` - -If you wish to serve a different directory, run: -```sh -$ ws -d ~/mysite/ -serving /Users/Lloyd/mysite at http://localhost:8000 -``` - -If you wish to override the default port (8000), use `--port` or `-p`: -```sh -$ ws --port 9000 -serving at http://localhost:9000 -``` - -To add compression, reducing bandwidth, increasing page load time (by 10-15% on my Macbook Air) -```sh -$ ws --compress -``` - -### Logging -Passing a value to `--log.format` will write an access log to `stdout`. - -Either use a built-in [morgan](https://github.com/expressjs/morgan) logger preset: -```sh -$ ws --log.format short -``` - -Or a custom [morgan](https://github.com/expressjs/morgan) log format: -```sh -$ ws -f ':method -> :url' -``` - -Or silence: -```sh -$ ws -f none -``` - -## Storing default options -To store per-project options, saving you the hassle of inputting them everytime, store them in the `local-web-server` property of your project's `package.json`: -```json -{ - "name": "my-project", - "version": "0.11.8", - "local-web-server":{ - "port": 8100 - } -} -``` - -Or in a `.local-web-server.json` file stored in the directory you want to serve (typically the root folder of your site): -```json -{ - "port": 8100, - "log.format": "tiny" -} -``` - -Or store global defaults in a `.local-web-server.json` file in your home directory. -```json -{ - "port": 3000, - "refresh-rate": 1000 -} -``` - -All stored defaults are overriden by options supplied at the command line. - -To view your stored defaults, run: - -```sh -$ ws --config -``` - -## mime-types -You can set additional mime-type/extension mappings, or override the defaults by setting a `mime` value in your local config. This value is passed directly to [mime.define()](https://github.com/broofa/node-mime#mimedefine). Example: - -```json -{ - "mime": { - "text/plain": [ "php", "pl" ] - } -} -``` - -## Use with Logstalgia -local-web-server is compatible with [logstalgia](http://code.google.com/p/logstalgia/). - -### Install Logstalgia -On MacOSX, install with [homebrew](http://brew.sh): -```sh -$ brew install logstalgia -``` - -Alternatively, [download a release for your system from github](https://github.com/acaudwell/Logstalgia/releases/latest). - -Then pipe the `logstalgia` output format directly into logstalgia for real-time visualisation: -```sh -$ ws -f logstalgia | logstalgia - -``` - -![local-web-server with logstalgia](http://75lb.github.io/local-web-server/logstagia.gif) - -## Use with glTail -To use with [glTail](http://www.fudgie.org), write your log to disk using the "default" format: -```sh -$ ws -f default > web.log -``` - -Then specify this file in your glTail config: - -```yaml -servers: - dev: - host: localhost - source: local - files: /Users/Lloyd/Documents/MySite/web.log - parser: apache - color: 0.2, 0.2, 1.0, 1.0 -``` - -* * * - -© 2015 Lloyd Brookes <75pound@gmail.com> diff --git a/test/compress/compress.js b/test/compress/compress.js deleted file mode 100644 index 84f057b..0000000 --- a/test/compress/compress.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict' -const test = require('tape') -const request = require('req-then') -const LocalWebServer = require('../../') -const c = require('../common') - -test('compress', function (t) { - t.plan(2) - const ws = new LocalWebServer() - ws.addCompression(true) - ws.addStatic(__dirname) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/big-file.txt', { headers: { 'Accept-Encoding': 'gzip' } }) - .then(response => { - t.strictEqual(response.res.statusCode, 200) - t.strictEqual(response.res.headers['content-encoding'], 'gzip') - }) - .then(server.close.bind(server)) - .catch(c.fail(t)) - }) -}) diff --git a/test/forbid/forbid.js b/test/forbid/forbid.js deleted file mode 100644 index c2d4910..0000000 --- a/test/forbid/forbid.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict' -const test = require('tape') -const request = require('req-then') -const LocalWebServer = require('../../') -const c = require('../common') - -test('forbid', function (t) { - t.plan(2) - const ws = new LocalWebServer() - ws.addBlacklist([ '*.php', '*.html' ]) - ws.addStatic(__dirname) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/two.php') - .then(c.checkResponse(t, 403)) - .then(() => request('http://localhost:8100/one.html')) - .then(c.checkResponse(t, 403)) - .then(server.close.bind(server)) - .catch(c.fail(t)) - }) -}) diff --git a/test/forbid/one.html b/test/forbid/one.html deleted file mode 100644 index 5626abf..0000000 --- a/test/forbid/one.html +++ /dev/null @@ -1 +0,0 @@ -one diff --git a/test/forbid/two.php b/test/forbid/two.php deleted file mode 100644 index abb2fca..0000000 --- a/test/forbid/two.php +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/log/log.js b/test/log/log.js deleted file mode 100644 index a90e2f6..0000000 --- a/test/log/log.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict' -const test = require('tape') -const request = require('req-then') -const LocalWebServer = require('../../') -const c = require('../common') - -test('logging', function (t) { - t.plan(2) - const ws = new LocalWebServer() - - const stream = require('stream').PassThrough() - stream.on('readable', () => { - let chunk = stream.read() - if (chunk) t.ok(/GET/.test(chunk.toString())) - }) - - ws.addLogging('common', { stream: stream }) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/') - .then(c.checkResponse(t, 404)) - .then(server.close.bind(server)) - .catch(c.fail(t)) - }) -}) diff --git a/test/mime/mime.js b/test/mime/mime.js deleted file mode 100644 index bb8cc44..0000000 --- a/test/mime/mime.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict' -const test = require('tape') -const request = require('req-then') -const LocalWebServer = require('../../') -const c = require('../common') - -test('mime override', function (t) { - t.plan(2) - const ws = new LocalWebServer() - ws.addMimeOverride({ 'text/plain': [ 'php' ] }) - ws.addStatic(__dirname) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/something.php') - .then(response => { - t.strictEqual(response.res.statusCode, 200) - t.ok(/text\/plain/.test(response.res.headers['content-type'])) - }) - .then(server.close.bind(server)) - .catch(c.fail(t)) - }) -}) diff --git a/test/mime/something.php b/test/mime/something.php deleted file mode 100644 index abb2fca..0000000 --- a/test/mime/something.php +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/mock/mock.js b/test/mock/mock.js deleted file mode 100644 index 28dccac..0000000 --- a/test/mock/mock.js +++ /dev/null @@ -1,150 +0,0 @@ -'use strict' -const test = require('tape') -const request = require('req-then') -const LocalWebServer = require('../../') -const c = require('../common') - -test('mock: simple response', function (t) { - t.plan(2) - const ws = new LocalWebServer() - ws.addMockResponses([ - { route: '/test', response: { body: 'test' } } - ]) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/test') - .then(c.checkResponse(t, 200, /test/)) - .then(server.close.bind(server)) - .catch(c.fail(t)) - }) -}) - -test('mock: method request filter', function (t) { - t.plan(3) - const ws = new LocalWebServer() - ws.addMockResponses([ - { - route: '/test', - request: { method: 'POST' }, - response: { body: 'test' } - } - ]) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/test') - .then(c.checkResponse(t, 404)) - .then(() => request('http://localhost:8100/test', { data: 'something' })) - .then(c.checkResponse(t, 200, /test/)) - .then(server.close.bind(server)) - .catch(c.fail(t)) - }) -}) - -test('mock: accepts request filter', function (t) { - t.plan(3) - const ws = new LocalWebServer() - ws.addMockResponses([ - { - route: '/test', - request: { accepts: 'text' }, - response: { body: 'test' } - } - ]) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/test', { headers: { Accept: '*/json' } }) - .then(c.checkResponse(t, 404)) - .then(() => request('http://localhost:8100/test', { headers: { Accept: 'text/plain' } })) - .then(c.checkResponse(t, 200, /test/)) - .then(server.close.bind(server)) - }) -}) - -test('mock: responses array', function (t) { - t.plan(4) - const ws = new LocalWebServer() - ws.addMockResponses([ - { - route: '/test', - responses: [ - { request: { method: 'GET' }, response: { body: 'get' } }, - { request: { method: 'POST' }, response: { body: 'post' } } - ] - } - ]) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/test') - .then(c.checkResponse(t, 200, /get/)) - .then(() => request('http://localhost:8100/test', { method: 'POST' })) - .then(c.checkResponse(t, 200, /post/)) - .then(server.close.bind(server)) - }) -}) - -test('mock: response function', function (t) { - t.plan(4) - const ws = new LocalWebServer() - ws.addMockResponses([ - { - route: '/test', - responses: [ - { request: { method: 'GET' }, response: ctx => ctx.body = 'get' }, - { request: { method: 'POST' }, response: ctx => ctx.body = 'post' } - ] - } - ]) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/test') - .then(c.checkResponse(t, 200, /get/)) - .then(() => request('http://localhost:8100/test', { method: 'POST' })) - .then(c.checkResponse(t, 200, /post/)) - .then(server.close.bind(server)) - }) -}) - -test('mock: response function args', function (t) { - t.plan(2) - const ws = new LocalWebServer() - ws.addMockResponses([ - { - route: '/test/:one', - responses: [ - { request: { method: 'GET' }, response: (ctx, one) => ctx.body = one } - ] - } - ]) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/test/yeah') - .then(c.checkResponse(t, 200, /yeah/)) - .then(server.close.bind(server)) - }) -}) - -test('mock: async response function', function (t) { - t.plan(2) - const ws = new LocalWebServer() - ws.addMockResponses([ - { - route: '/test', - responses: { - response: function (ctx) { - return new Promise((resolve, reject) => { - setTimeout(() => { - ctx.body = 'test' - resolve() - }, 10) - }) - } - } - } - ]) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/test') - .then(c.checkResponse(t, 200, /test/)) - .then(server.close.bind(server)) - }) -}) diff --git a/test/mock/one.html b/test/mock/one.html deleted file mode 100644 index 5626abf..0000000 --- a/test/mock/one.html +++ /dev/null @@ -1 +0,0 @@ -one diff --git a/test/proxy/file.txt b/test/proxy/file.txt deleted file mode 100644 index 5626abf..0000000 --- a/test/proxy/file.txt +++ /dev/null @@ -1 +0,0 @@ -one diff --git a/test/proxy/one.html b/test/proxy/one.html deleted file mode 100644 index 5626abf..0000000 --- a/test/proxy/one.html +++ /dev/null @@ -1 +0,0 @@ -one diff --git a/test/proxy/rewrite-proxy.js b/test/proxy/rewrite-proxy.js deleted file mode 100644 index 3fea168..0000000 --- a/test/proxy/rewrite-proxy.js +++ /dev/null @@ -1,73 +0,0 @@ -'use strict' -const test = require('tape') -const request = require('req-then') -const LocalWebServer = require('../../') -const http = require('http') -const c = require('../common') - -test('rewrite: proxy', function (t) { - t.plan(2) - const ws = new LocalWebServer() - ws.addRewrite([ - { from: '/test/*', to: 'http://registry.npmjs.org/$1' } - ]) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/test/') - .then(c.checkResponse(t, 200, /db_name/)) - .then(server.close.bind(server)) - .catch(c.fail(t)) - }) -}) - -test('rewrite: proxy, POST', function (t) { - t.plan(1) - const ws = new LocalWebServer() - ws.addRewrite([ - { from: '/test/*', to: 'http://registry.npmjs.org/' } - ]) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/test/', { data: {} }) - .then(c.checkResponse(t, 405)) - .then(server.close.bind(server)) - .catch(c.fail(t)) - }) -}) - -test('rewrite: proxy, two url tokens', function (t) { - t.plan(2) - const ws = new LocalWebServer() - ws.addRewrite([ - { from: '/:package/:version', to: 'http://registry.npmjs.org/:package/:version' } - ]) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/command-line-args/1.0.0') - .then(c.checkResponse(t, 200, /command-line-args/)) - .then(server.close.bind(server)) - .catch(c.fail(t)) - }) -}) - -test('rewrite: proxy with port', function (t) { - t.plan(2) - const ws1 = new LocalWebServer() - ws1.addStatic(__dirname) - - const ws2 = new LocalWebServer() - ws2.addRewrite([ - { from: '/test/*', to: 'http://localhost:9000/$1' } - ]) - const server1 = ws1.getServer() - const server2 = ws2.getServer() - server1.listen(9000, () => { - server2.listen(8100, () => { - request('http://localhost:8100/test/file.txt') - .then(c.checkResponse(t, 200, /one/)) - .then(server1.close.bind(server1)) - .then(server2.close.bind(server2)) - .catch(c.fail(t)) - }) - }) -}) diff --git a/test/rewrite/one.html b/test/rewrite/one.html deleted file mode 100644 index 5626abf..0000000 --- a/test/rewrite/one.html +++ /dev/null @@ -1 +0,0 @@ -one diff --git a/test/rewrite/rewrite.js b/test/rewrite/rewrite.js deleted file mode 100644 index cdce7e0..0000000 --- a/test/rewrite/rewrite.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict' -const test = require('tape') -const request = require('req-then') -const LocalWebServer = require('../../') -const c = require('../common') - -test('rewrite local', function (t) { - t.plan(2) - const ws = new LocalWebServer() - ws.addRewrite([ { from: '/two.html', to: '/one.html' } ]) - ws.addStatic(__dirname) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/two.html') - .then(c.checkResponse(t, 200, /one/)) - .then(server.close.bind(server)) - .catch(c.fail(t)) - }) -}) diff --git a/test/serve-index/serve-index.js b/test/serve-index/serve-index.js deleted file mode 100644 index 3ca09d6..0000000 --- a/test/serve-index/serve-index.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict' -const test = require('tape') -const request = require('req-then') -const LocalWebServer = require('../../') -const c = require('../common') - -test('static', function (t) { - t.plan(3) - const ws = new LocalWebServer() - ws.addIndex(__dirname, { icons: true }) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/') - .then(c.checkResponse(t, 200, [ /listing directory/, /class="icon/ ])) - .then(server.close.bind(server)) - .catch(c.fail(t)) - }) -}) diff --git a/test/spa/one.txt b/test/spa/one.txt deleted file mode 100644 index 5626abf..0000000 --- a/test/spa/one.txt +++ /dev/null @@ -1 +0,0 @@ -one diff --git a/test/spa/spa.js b/test/spa/spa.js deleted file mode 100644 index 38dbc50..0000000 --- a/test/spa/spa.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict' -const test = require('tape') -const request = require('req-then') -const LocalWebServer = require('../../') -const c = require('../common') - -test('spa', function (t) { - t.plan(6) - const ws = new LocalWebServer() - ws.addSpa('one.txt') - ws.addStatic(__dirname) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/asdf', { headers: { accept: 'text/html' } }) - .then(c.checkResponse(t, 200, /one/)) - /* html requests for missing files with extensions do not redirect to spa */ - .then(() => request('http://localhost:8100/asdf.txt', { headers: { accept: 'text/html' } })) - .then(c.checkResponse(t, 404)) - /* existing static file */ - .then(() => request('http://localhost:8100/two.txt')) - .then(c.checkResponse(t, 200, /two/)) - /* not a text/html request - does not redirect to spa */ - .then(() => request('http://localhost:8100/asdf', { headers: { accept: 'application/json' } })) - .then(c.checkResponse(t, 404)) - .then(server.close.bind(server)) - .catch(c.fail(t)) - }) -}) diff --git a/test/spa/two.txt b/test/spa/two.txt deleted file mode 100644 index f719efd..0000000 --- a/test/spa/two.txt +++ /dev/null @@ -1 +0,0 @@ -two diff --git a/test/static/file.txt b/test/static/file.txt deleted file mode 100644 index 9daeafb..0000000 --- a/test/static/file.txt +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/test/static/static.js b/test/static/static.js deleted file mode 100644 index 92cf1f8..0000000 --- a/test/static/static.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict' -const test = require('tape') -const request = require('req-then') -const LocalWebServer = require('../../') -const c = require('../common') - -test('static', function (t) { - t.plan(2) - const ws = new LocalWebServer() - ws.addStatic(__dirname, { index: 'file.txt' }) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/') - .then(c.checkResponse(t, 200, /test/)) - .then(server.close.bind(server)) - .catch(c.fail(t)) - }) -}) diff --git a/test/test.js b/test/test.js index a8a7a7c..23c626b 100644 --- a/test/test.js +++ b/test/test.js @@ -8,15 +8,17 @@ const path = require('path') test('stack', function (t) { t.plan(2) const ws = new LocalWebServer({ - stack: [ path.resolve(__dirname, 'test-middleware.js') ] - }) - const server = ws.getServer() - server.listen(8100, () => { - request('http://localhost:8100/') - .then(c.checkResponse(t, 200, /1234512345/)) - .then(server.close.bind(server)) - .catch(c.fail(t)) + stack: [ path.resolve(__dirname, 'test-middleware.js') ], + port: 8100 }) + ws.listen() + .then(() => { + return request('http://localhost:8100/') + .then(c.checkResponse(t, 200, /1234512345/)) + .then(ws.close.bind(ws)) + .catch(c.fail(t)) + }) + .catch(c.fail(t)) }) test('https', function (t) { @@ -28,9 +30,9 @@ test('https', function (t) { }) ws.listen() .then(() => { - request('https://localhost:8100/') + return request('https://localhost:8100/') .then(c.checkResponse(t, 200, /1234512345/)) .then(ws.close.bind(ws)) - .catch(c.fail(t)) }) + .catch(c.fail(t)) })