Skip to content

Commit

Permalink
[Tests] simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed May 6, 2023
1 parent 7e7c3d0 commit c656ee5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/no_only.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);
});
}
);
Expand Down

0 comments on commit c656ee5

Please sign in to comment.