From 684a1fec15f85338a139e40c6cb93e5fdec5b502 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 26 Sep 2023 10:06:46 +0300 Subject: [PATCH] fix: node 20 skip text changes --- packages/testwatch/nodeVersion.js | 2 ++ packages/testwatch/tests/index.test.js | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/testwatch/nodeVersion.js b/packages/testwatch/nodeVersion.js index 26d36b8..5c0d697 100644 --- a/packages/testwatch/nodeVersion.js +++ b/packages/testwatch/nodeVersion.js @@ -3,5 +3,7 @@ const [major, minor] = process.versions.node.split('.').map(Number); module.exports = { + major, + minor, isSupported: major > 20 || (major === 20 && minor >= 3) || (major === 18 && minor >= 17), }; diff --git a/packages/testwatch/tests/index.test.js b/packages/testwatch/tests/index.test.js index 88aa214..f61113d 100644 --- a/packages/testwatch/tests/index.test.js +++ b/packages/testwatch/tests/index.test.js @@ -6,7 +6,7 @@ const { once } = require('node:events'); const assert = require('node:assert'); const path = require('node:path'); const chalk = require('chalk'); -const { isSupported } = require('../nodeVersion'); +const { isSupported, major, minor } = require('../nodeVersion'); const clear = '\x1Bc'; const esc = '\x1b'; @@ -38,6 +38,8 @@ Filter Test const filterFilesPrompt = filterTestsPrompt.replace('test', 'file').replace('Test', 'File'); const debugOutput = process.env.DEBUG || process.argv.includes('--debug'); +const skipText = major >= 20 && minor >= 7 ? '# test name does not match pattern' : '# SKIP'; + function debug(str) { if (debugOutput) { const delimiter = chalk.bgWhite('--CLEAR--'); @@ -174,8 +176,8 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod '', '', `${tests - .replace('✔ j - sum (*ms)', '﹣ j - sum (*ms) # SKIP') - .replace('✔ index - sum (*ms)', '﹣ index - sum (*ms) # SKIP') + .replace('✔ j - sum (*ms)', `﹣ j - sum (*ms) ${skipText}`) + .replace('✔ index - sum (*ms)', `﹣ index - sum (*ms) ${skipText}`) }\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`, ]); }); @@ -238,7 +240,7 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod const activeFilters = '\nActive Filters: file name **/index*.*, test name /sum/\n'; assert.strictEqual(stderr, ''); assert.strictEqual(outputs.length, 11); - assert.strictEqual(outputs[10], `${testsRun[1].replace('✔ index - subtraction (*ms)', '﹣ index - subtraction (*ms) # SKIP')}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`); + assert.strictEqual(outputs[10], `${testsRun[1].replace('✔ index - subtraction (*ms)', `﹣ index - subtraction (*ms) ${skipText}`)}\n${compactMenu}\n${clearLines}${activeFilters}${mainMenuWithFilters}\n`); }); it('should mention when no files found', async () => {