From e4afd79d803a570c045a29350b303e2a012f5ff9 Mon Sep 17 00:00:00 2001 From: sogaani Date: Mon, 30 Jul 2018 20:09:38 +0900 Subject: [PATCH] Add http2 tests --- .travis.yml | 6 ++++++ package.json | 2 ++ test/express.js | 6 +++++- test/http.js | 4 ++++ test/restify.js | 4 ++++ test/test.js | 4 ++++ 6 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8031a7e..23edc08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,8 @@ node_js: - "4.8" - "5.12" - "6.12" + - "8.11" + - "10.7" sudo: false cache: directories: @@ -25,5 +27,9 @@ script: - "test ! -z $(npm -ps ls istanbul) || npm test" - "test -z $(npm -ps ls istanbul) || npm run-script test-ci" - "test -z $(npm -ps ls eslint) || npm run-script lint" + # Run test script with http2 + - "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 8 || npm install https://github.com/sogaani/express.git#initial-support-http2 https://github.com/sogaani/supertest.git#http2" + - "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 8 || npm test-http2" + - "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 8 || npm run-script test-http2-ci" after_script: - "test -e ./coverage/lcov.info && npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" diff --git a/package.json b/package.json index 86734d6..34ac32e 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,9 @@ "scripts": { "lint": "eslint .", "test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/", + "test-http2": "EXPOSE_HTTP2=1 mocha --require test/support/env --reporter spec --bail --check-leaks test/", "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/", + "test-http2-ci": "EXPOSE_HTTP2=1 istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/" } } diff --git a/test/express.js b/test/express.js index a53ad7e..6bdac65 100644 --- a/test/express.js +++ b/test/express.js @@ -6,6 +6,10 @@ var assert = require( "assert" ) , cookies = require( "../" ).express , request = require('supertest') +if(process.env.EXPOSE_HTTP2){ + http = require( "http2" ) +} + describe('Express', function () { var server var header @@ -65,7 +69,7 @@ describe('Express', function () { ) }) - server = require('http').createServer(app).listen() + server = http.createServer(app).listen() }) it('should set cookies', function (done) { diff --git a/test/http.js b/test/http.js index e8fc275..8e8ea6a 100644 --- a/test/http.js +++ b/test/http.js @@ -5,6 +5,10 @@ var assert = require( "assert" ) , Cookies = require( "../" ) , request = require('supertest') +if(process.env.EXPOSE_HTTP2){ + http = require( "http2" ) +} + describe('HTTP', function () { var server var header diff --git a/test/restify.js b/test/restify.js index 49657c9..0c32219 100644 --- a/test/restify.js +++ b/test/restify.js @@ -1,3 +1,6 @@ +if(Number(process.version.split('.')[0].slice(1)) >= 8){ + process.EventEmitter = require('events') +} var assert = require('assert') , restify = require('restify') , keys = require('keygrip')(['a', 'b']) @@ -5,6 +8,7 @@ var assert = require('assert') , Cookies = require('../') , request = require('supertest') +if(!process.env.EXPOSE_HTTP2) describe('Restify', function () { var header var server diff --git a/test/test.js b/test/test.js index f8699b6..7b1ceed 100644 --- a/test/test.js +++ b/test/test.js @@ -4,6 +4,10 @@ var Cookies = require('..') var http = require('http') var request = require('supertest') +if(process.env.EXPOSE_HTTP2){ + http = require( "http2" ) +} + describe('new Cookies(req, res, [options])', function () { it('should create new cookies instance', function (done) { request(createServer(function (req, res, cookies) {