Skip to content

Commit 83bc381

Browse files
committedMay 6, 2023
[Tests] simplify tests
1 parent a892b65 commit 83bc381

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

‎test/no_only.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ var stripFullStack = require('./common').stripFullStack;
88

99
var tapeBin = 'node ' + path.join(__dirname, '../bin/tape');
1010

11-
var expectedExitCodeFailure = (/^0\.10\.\d+$/).test(process.versions.node);
1211
var expectedStackTraceBug = (/^3\.[012]\.\d+$/).test(process.versions.node); // https://github.com/nodejs/node/issues/2581
12+
var expectedExitCodeOnError = (/^0\.(?:9|10)/).test(process.versions.node) ? 8 : 1; // node v0.9 sets this exit code to 8, for some reason
1313

1414
tap.test(
1515
'Should throw error when --no-only is passed via cli and there is a .only test',
16-
{ todo: expectedExitCodeFailure || expectedStackTraceBug ? 'Fails on these node versions' : false },
16+
{ todo: expectedStackTraceBug ? 'Fails on these node versions' : false },
1717
function (tt) {
1818
tt.plan(3);
1919

@@ -22,14 +22,14 @@ tap.test(
2222
}, function (err, stdout, stderr) {
2323
tt.same(stdout.toString('utf8'), '');
2424
tt.match(stripFullStack(stderr.toString('utf8')).join('\n'), /Error: `only` tests are prohibited\n/);
25-
tt.equal(err.code, 1);
25+
tt.equal(err.code, expectedExitCodeOnError);
2626
});
2727
}
2828
);
2929

3030
tap.test(
3131
'Should throw error when NODE_TAPE_NO_ONLY_TEST is passed via envs and there is an .only test',
32-
{ todo: expectedExitCodeFailure || expectedStackTraceBug ? 'Fails on these node versions' : false },
32+
{ todo: expectedStackTraceBug ? 'Fails on these node versions' : false },
3333
function (tt) {
3434
tt.plan(3);
3535

@@ -39,14 +39,14 @@ tap.test(
3939
}, function (err, stdout, stderr) {
4040
tt.same(stdout.toString('utf8'), '');
4141
tt.match(stripFullStack(stderr.toString('utf8')).join('\n'), /Error: `only` tests are prohibited\n/);
42-
tt.equal(err.code, 1);
42+
tt.equal(err.code, expectedExitCodeOnError);
4343
});
4444
}
4545
);
4646

4747
tap.test(
4848
'Should override NODE_TAPE_NO_ONLY_TEST env if --no-only is passed from cli',
49-
{ todo: expectedExitCodeFailure || expectedStackTraceBug ? 'Fails on these node versions' : false },
49+
{ todo: expectedStackTraceBug ? 'Fails on these node versions' : false },
5050
function (tt) {
5151
tt.plan(3);
5252

@@ -56,7 +56,7 @@ tap.test(
5656
}, function (err, stdout, stderr) {
5757
tt.same(stdout.toString('utf8'), '');
5858
tt.match(stripFullStack(stderr.toString('utf8')).join('\n'), /Error: `only` tests are prohibited\n/);
59-
tt.equal(err.code, 1);
59+
tt.equal(err.code, expectedExitCodeOnError);
6060
});
6161
}
6262
);

0 commit comments

Comments
 (0)
Please sign in to comment.