Merge pull request #289 from bitinn/2.x-fix-tests-for-node-8

2.x branch: fix testcases for node 8 and npm 5
This commit is contained in:
David Frank 2017-06-03 18:18:34 +08:00 committed by GitHub
commit 5060ac10f1
4 changed files with 10 additions and 2 deletions

4
.gitignore vendored
View File

@ -33,3 +33,7 @@ node_modules
# Babel-compiled files
lib
# Ignore package manager lock files
package-lock.json
yarn.lock

View File

@ -13,11 +13,12 @@ This is a major release. Check [our upgrade guide](https://github.com/bitinn/nod
- Major: Node.js 0.10.x and 0.12.x support is dropped
- Major: `require('node-fetch/lib/response')` etc. is now unsupported; use `require('node-fetch').Response` or ES6 module imports
- Enhance: start testing on Node.js 4, 6, 7
- Enhance: start testing on Node.js 4, 6, 8 LTS
- Enhance: use Rollup to produce a distributed bundle (less memory overhead and faster startup)
- Enhance: make `Object.prototype.toString()` on Headers, Requests, and Responses return correct class strings
- Other: rewrite in ES2015 using Babel
- Other: use Codecov for code coverage tracking
- Other: update package.json script for npm 5
### HTTP requests

View File

@ -14,7 +14,7 @@
},
"scripts": {
"build": "cross-env BABEL_ENV=rollup rollup -c",
"prepublish": "npm run build",
"prepare": "npm run build",
"test": "cross-env BABEL_ENV=test mocha --compilers js:babel-register test/test.js",
"report": "cross-env BABEL_ENV=coverage nyc --reporter lcov --reporter text mocha -R spec test/test.js",
"coverage": "cross-env BABEL_ENV=coverage nyc --reporter json --reporter text mocha -R spec test/test.js && codecov -f coverage/coverage-final.json"

View File

@ -10,6 +10,9 @@ export default class TestServer {
this.server = http.createServer(this.router);
this.port = 30001;
this.hostname = 'localhost';
// node 8 default keepalive timeout is 5000ms
// make it shorter here as we want to close server quickly at the end of tests
this.server.keepAliveTimeout = 1000;
this.server.on('error', function(err) {
console.log(err.stack);
});