From c656ee52626e0e4992e893e41e1ae81ecb5d68a2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 5 May 2023 23:45:49 -0700 Subject: [PATCH] [Tests] simplify tests --- test/no_only.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/no_only.js b/test/no_only.js index 4e755c98..95ad07eb 100644 --- a/test/no_only.js +++ b/test/no_only.js @@ -8,12 +8,12 @@ var stripFullStack = require('./common').stripFullStack; var tapeBin = 'node ' + path.join(__dirname, '../bin/tape'); -var expectedExitCodeFailure = (/^0\.10\.\d+$/).test(process.versions.node); var expectedStackTraceBug = (/^3\.[012]\.\d+$/).test(process.versions.node); // https://github.com/nodejs/node/issues/2581 +var expectedExitCodeOnError = (/^0\.(?:9|10)/).test(process.versions.node) ? 8 : 1; // node v0.9 sets this exit code to 8, for some reason tap.test( 'Should throw error when --no-only is passed via cli and there is a .only test', - { todo: expectedExitCodeFailure || expectedStackTraceBug ? 'Fails on these node versions' : false }, + { todo: expectedStackTraceBug ? 'Fails on these node versions' : false }, function (tt) { tt.plan(3); @@ -22,14 +22,14 @@ tap.test( }, function (err, stdout, stderr) { tt.same(stdout.toString('utf8'), ''); tt.match(stripFullStack(stderr.toString('utf8')).join('\n'), /Error: `only` tests are prohibited\n/); - tt.equal(err.code, 1); + tt.equal(err.code, expectedExitCodeOnError); }); } ); tap.test( 'Should throw error when NODE_TAPE_NO_ONLY_TEST is passed via envs and there is an .only test', - { todo: expectedExitCodeFailure || expectedStackTraceBug ? 'Fails on these node versions' : false }, + { todo: expectedStackTraceBug ? 'Fails on these node versions' : false }, function (tt) { tt.plan(3); @@ -39,14 +39,14 @@ tap.test( }, function (err, stdout, stderr) { tt.same(stdout.toString('utf8'), ''); tt.match(stripFullStack(stderr.toString('utf8')).join('\n'), /Error: `only` tests are prohibited\n/); - tt.equal(err.code, 1); + tt.equal(err.code, expectedExitCodeOnError); }); } ); tap.test( 'Should override NODE_TAPE_NO_ONLY_TEST env if --no-only is passed from cli', - { todo: expectedExitCodeFailure || expectedStackTraceBug ? 'Fails on these node versions' : false }, + { todo: expectedStackTraceBug ? 'Fails on these node versions' : false }, function (tt) { tt.plan(3); @@ -56,7 +56,7 @@ tap.test( }, function (err, stdout, stderr) { tt.same(stdout.toString('utf8'), ''); tt.match(stripFullStack(stderr.toString('utf8')).join('\n'), /Error: `only` tests are prohibited\n/); - tt.equal(err.code, 1); + tt.equal(err.code, expectedExitCodeOnError); }); } );