From 617aa06f68da25024b18285b22c3ea12e7c8fb7d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 11 Jul 2019 20:03:08 -0400 Subject: [PATCH] tests: run express tests on appropriate Node.js versions --- test/3.x/async_helpers.js | 6 ++++++ test/3.x/index.js | 5 +++++ test/3.x/no_layout_app.js | 6 ++++++ test/3.x/view_engine.js | 6 ++++++ test/4.x/async_helpers.js | 6 ++++++ test/4.x/index.js | 5 +++++ test/4.x/no_layout_app.js | 6 ++++++ test/4.x/view_engine.js | 6 ++++++ test/support/utils.js | 5 +++++ 9 files changed, 51 insertions(+) diff --git a/test/3.x/async_helpers.js b/test/3.x/async_helpers.js index 439ac2f..7e7e2a4 100644 --- a/test/3.x/async_helpers.js +++ b/test/3.x/async_helpers.js @@ -1,5 +1,6 @@ var path = require('path') var request = require('supertest') +var utils = require('../support/utils') var FIXTURES_DIR = path.join(__dirname, '..', 'fixtures') @@ -11,6 +12,11 @@ var app = null suite('express 3.x async helpers') before(function () { + if (utils.nodeVersionCompare(10.0) >= 0) { + this.skip() + return + } + var express = require('express') var hbs = require('../../').create() diff --git a/test/3.x/index.js b/test/3.x/index.js index 10c0aa8..4af51c6 100644 --- a/test/3.x/index.js +++ b/test/3.x/index.js @@ -6,6 +6,11 @@ var utils = require('../support/utils') suite('express 3.x') before(function (done) { + if (utils.nodeVersionCompare(10.0) >= 0) { + this.skip() + return done() + } + var env = utils.childEnvironment() this.timeout(30000) diff --git a/test/3.x/no_layout_app.js b/test/3.x/no_layout_app.js index c574e34..809a92d 100644 --- a/test/3.x/no_layout_app.js +++ b/test/3.x/no_layout_app.js @@ -1,5 +1,6 @@ var path = require('path') var request = require('supertest') +var utils = require('../support/utils') var FIXTURES_DIR = path.join(__dirname, '..', 'fixtures') @@ -12,6 +13,11 @@ var app = null suite('express 3.x no layout') before(function () { + if (utils.nodeVersionCompare(10.0) >= 0) { + this.skip() + return + } + var express = require('express') var hbs = require('../../') diff --git a/test/3.x/view_engine.js b/test/3.x/view_engine.js index 96872e4..8b940f0 100644 --- a/test/3.x/view_engine.js +++ b/test/3.x/view_engine.js @@ -1,5 +1,6 @@ var path = require('path') var request = require('supertest') +var utils = require('../support/utils') var FIXTURES_DIR = path.join(__dirname, '..', 'fixtures') @@ -11,6 +12,11 @@ var app = null suite('express 3.x view engine') before(function () { + if (utils.nodeVersionCompare(10.0) >= 0) { + this.skip() + return + } + var express = require('express') var hbs = require('../../') diff --git a/test/4.x/async_helpers.js b/test/4.x/async_helpers.js index 9b8b30f..59cca1c 100644 --- a/test/4.x/async_helpers.js +++ b/test/4.x/async_helpers.js @@ -1,5 +1,6 @@ var path = require('path') var request = require('supertest') +var utils = require('../support/utils') var FIXTURES_DIR = path.join(__dirname, '..', 'fixtures') @@ -11,6 +12,11 @@ var app = null suite('express 4.x async helpers') before(function () { + if (utils.nodeVersionCompare(0.10) <= 0) { + this.skip() + return + } + var express = require('express') var hbs = require('../../').create() diff --git a/test/4.x/index.js b/test/4.x/index.js index d9a0246..663479e 100644 --- a/test/4.x/index.js +++ b/test/4.x/index.js @@ -6,6 +6,11 @@ var utils = require('../support/utils') suite('express 4.x') before(function (done) { + if (utils.nodeVersionCompare(0.10) <= 0) { + this.skip() + return done() + } + var env = utils.childEnvironment() this.timeout(30000) diff --git a/test/4.x/no_layout_app.js b/test/4.x/no_layout_app.js index dd89a60..6e7deef 100644 --- a/test/4.x/no_layout_app.js +++ b/test/4.x/no_layout_app.js @@ -1,5 +1,6 @@ var path = require('path') var request = require('supertest') +var utils = require('../support/utils') var FIXTURES_DIR = path.join(__dirname, '..', 'fixtures') @@ -13,6 +14,11 @@ var app = null suite('express 4.x no layout') before(function () { + if (utils.nodeVersionCompare(0.10) <= 0) { + this.skip() + return + } + var express = require('express') var hbs = require('../../') diff --git a/test/4.x/view_engine.js b/test/4.x/view_engine.js index b89a50c..65ac9e0 100644 --- a/test/4.x/view_engine.js +++ b/test/4.x/view_engine.js @@ -1,5 +1,6 @@ var path = require('path') var request = require('supertest') +var utils = require('../support/utils') var FIXTURES_DIR = path.join(__dirname, '..', 'fixtures') @@ -11,6 +12,11 @@ var app = null suite('express 4.x view engine') before(function () { + if (utils.nodeVersionCompare(0.10) <= 0) { + this.skip() + return + } + var express = require('express') var hbs = require('../../') diff --git a/test/support/utils.js b/test/support/utils.js index e04b0d6..d625897 100644 --- a/test/support/utils.js +++ b/test/support/utils.js @@ -1,6 +1,7 @@ 'use strict' module.exports.childEnvironment = childEnvironment +module.exports.nodeVersionCompare = nodeVersionCompare function childEnvironment () { var env = Object.create(null) @@ -14,3 +15,7 @@ function childEnvironment () { return env } + +function nodeVersionCompare (version) { + return parseFloat(process.version.substr(1).split('.').slice(0, 2).join('.')) - version +}