From 308a5cbb354743c9a41d2f0b12cae66676dbfd90 Mon Sep 17 00:00:00 2001 From: nathanhleung Date: Sat, 28 Jun 2025 18:54:18 -0700 Subject: [PATCH 1/3] test: skip query test on node <22 --- test/route.js | 5 ++++- test/router.js | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/test/route.js b/test/route.js index dd51298..f8ea2db 100644 --- a/test/route.js +++ b/test/route.js @@ -254,7 +254,10 @@ describe('Router', function () { // CONNECT is tricky and supertest doesn't support it return } - if (method === 'query' && process.version.startsWith('v21')) { + + // Skipping HTTP QUERY tests below Node 22, QUERY wasn't fully supported by Node until 22 + const majorVersion = Number(process.versions.node.split('.')[0]); + if (method === 'query' && majorVersion < 22) { return } diff --git a/test/router.js b/test/router.js index b440e40..c548fd4 100644 --- a/test/router.js +++ b/test/router.js @@ -51,7 +51,10 @@ describe('Router', function () { // CONNECT is tricky and supertest doesn't support it return cb() } - if (method === 'query' && process.version.startsWith('v21')) { + + // Skipping HTTP QUERY tests below Node 22, QUERY wasn't fully supported by Node until 22 + const majorVersion = Number(process.versions.node.split('.')[0]); + if (method === 'query' && majorVersion < 22) { return cb() } @@ -317,7 +320,10 @@ describe('Router', function () { // CONNECT is tricky and supertest doesn't support it return } - if (method === 'query' && process.version.startsWith('v21')) { + + // Skipping HTTP QUERY tests below Node 22, QUERY wasn't fully supported by Node until 22 + const majorVersion = Number(process.versions.node.split('.')[0]); + if (method === 'query' && majorVersion < 22) { return } From 3a0c37e83be7763f9bb3e8ca062f0fea6cee852a Mon Sep 17 00:00:00 2001 From: nathanhleung Date: Sat, 28 Jun 2025 21:29:31 -0700 Subject: [PATCH 2/3] refactor: split query skip logic into separate utility --- test/route.js | 5 ++--- test/router.js | 9 +++------ test/support/utils.js | 7 +++++++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/test/route.js b/test/route.js index f8ea2db..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 () { @@ -255,9 +256,7 @@ describe('Router', function () { return } - // Skipping HTTP QUERY tests below Node 22, QUERY wasn't fully supported by Node until 22 - const majorVersion = Number(process.versions.node.split('.')[0]); - if (method === 'query' && majorVersion < 22) { + if (shouldSkipQueryHttpMethod()) { return } diff --git a/test/router.js b/test/router.js index c548fd4..6b10888 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 () { @@ -52,9 +53,7 @@ describe('Router', function () { return cb() } - // Skipping HTTP QUERY tests below Node 22, QUERY wasn't fully supported by Node until 22 - const majorVersion = Number(process.versions.node.split('.')[0]); - if (method === 'query' && majorVersion < 22) { + if (shouldSkipQueryHttpMethod()) { return cb() } @@ -321,9 +320,7 @@ describe('Router', function () { return } - // Skipping HTTP QUERY tests below Node 22, QUERY wasn't fully supported by Node until 22 - const majorVersion = Number(process.versions.node.split('.')[0]); - if (method === 'query' && majorVersion < 22) { + if (shouldSkipQueryHttpMethod()) { return } diff --git a/test/support/utils.js b/test/support/utils.js index 2fab2fb..e9dac28 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; +} \ No newline at end of file From 46a0377ca918c1f8d9d73a1493588017ccf263fc Mon Sep 17 00:00:00 2001 From: nathanhleung Date: Sat, 28 Jun 2025 21:30:48 -0700 Subject: [PATCH 3/3] style: lint --- test/router.js | 2 +- test/support/utils.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/router.js b/test/router.js index 6b10888..b72ce1e 100644 --- a/test/router.js +++ b/test/router.js @@ -319,7 +319,7 @@ describe('Router', function () { // CONNECT is tricky and supertest doesn't support it return } - + if (shouldSkipQueryHttpMethod()) { return } diff --git a/test/support/utils.js b/test/support/utils.js index e9dac28..96b32d4 100644 --- a/test/support/utils.js +++ b/test/support/utils.js @@ -143,7 +143,7 @@ function shouldNotHaveHeader (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; -} \ No newline at end of file +function shouldSkipQueryHttpMethod () { + const majorVersion = Number(process.versions.node.split('.')[0]) + return majorVersion < 22 +}