diff --git a/test/route.js b/test/route.js index dd51298..81f7c04 100644 --- a/test/route.js +++ b/test/route.js @@ -11,6 +11,7 @@ const shouldHaveBody = utils.shouldHaveBody const shouldHitHandle = utils.shouldHitHandle const shouldNotHaveBody = utils.shouldNotHaveBody const shouldNotHitHandle = utils.shouldNotHitHandle +const shouldSkipQueryHttpMethod = utils.shouldSkipQueryHttpMethod const methods = utils.methods describe('Router', function () { @@ -254,7 +255,8 @@ describe('Router', function () { // CONNECT is tricky and supertest doesn't support it return } - if (method === 'query' && process.version.startsWith('v21')) { + + if (shouldSkipQueryHttpMethod()) { return } diff --git a/test/router.js b/test/router.js index b440e40..b72ce1e 100644 --- a/test/router.js +++ b/test/router.js @@ -12,6 +12,7 @@ const shouldHaveBody = utils.shouldHaveBody const shouldHitHandle = utils.shouldHitHandle const shouldNotHaveBody = utils.shouldNotHaveBody const shouldNotHitHandle = utils.shouldNotHitHandle +const shouldSkipQueryHttpMethod = utils.shouldSkipQueryHttpMethod const methods = utils.methods describe('Router', function () { @@ -51,7 +52,8 @@ describe('Router', function () { // CONNECT is tricky and supertest doesn't support it return cb() } - if (method === 'query' && process.version.startsWith('v21')) { + + if (shouldSkipQueryHttpMethod()) { return cb() } @@ -317,7 +319,8 @@ describe('Router', function () { // CONNECT is tricky and supertest doesn't support it return } - if (method === 'query' && process.version.startsWith('v21')) { + + if (shouldSkipQueryHttpMethod()) { return } diff --git a/test/support/utils.js b/test/support/utils.js index 2fab2fb..96b32d4 100644 --- a/test/support/utils.js +++ b/test/support/utils.js @@ -15,6 +15,7 @@ exports.shouldHaveBody = shouldHaveBody exports.shouldNotHaveBody = shouldNotHaveBody exports.shouldHitHandle = shouldHitHandle exports.shouldNotHitHandle = shouldNotHitHandle +exports.shouldSkipQueryHttpMethod = shouldSkipQueryHttpMethod exports.methods = methods function createHitHandle (num) { @@ -140,3 +141,9 @@ function shouldNotHaveHeader (header) { assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header) } } + +// Skipping HTTP QUERY tests below Node 22, QUERY wasn't fully supported by Node until 22 +function shouldSkipQueryHttpMethod () { + const majorVersion = Number(process.versions.node.split('.')[0]) + return majorVersion < 22 +}