Skip to content

Commit

Permalink
integration tests will now fail with less useless information
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Jun 16, 2017
1 parent d878e74 commit f06f8ff
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 46 deletions.
5 changes: 4 additions & 1 deletion test/integration/hooks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ describe('hooks', function () {
runMocha('cascade.fixture.js', args, function (err, res) {
var lines, expected;

assert(!err);
if (err) {
done(err);
return;
}

lines = res.output.split(splitRegExp).map(function (line) {
return line.trim();
Expand Down
15 changes: 12 additions & 3 deletions test/integration/only.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ describe('.only()', function () {
describe('bdd', function () {
it('should run only tests that marked as `only`', function (done) {
run('options/only/bdd.fixture.js', ['--ui', 'bdd'], function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 11);
assert.equal(res.stats.failures, 0);
Expand All @@ -20,7 +23,10 @@ describe('.only()', function () {
describe('tdd', function () {
it('should run only tests that marked as `only`', function (done) {
run('options/only/tdd.fixture.js', ['--ui', 'tdd'], function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 8);
assert.equal(res.stats.failures, 0);
Expand All @@ -33,7 +39,10 @@ describe('.only()', function () {
describe('qunit', function () {
it('should run only tests that marked as `only`', function (done) {
run('options/only/qunit.fixture.js', ['--ui', 'qunit'], function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 5);
assert.equal(res.stats.failures, 0);
Expand Down
80 changes: 64 additions & 16 deletions test/integration/options.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ describe('options', function () {

it('should fail synchronous specs', function (done) {
run('options/async-only-sync.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.failures, 1);
Expand All @@ -25,7 +28,10 @@ describe('options', function () {

it('should allow asynchronous specs', function (done) {
run('options/async-only-async.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 1);
assert.equal(res.stats.failures, 0);
Expand All @@ -44,7 +50,10 @@ describe('options', function () {

it('should stop after the first error', function (done) {
run('options/bail.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 1);
assert.equal(res.stats.failures, 1);
Expand All @@ -64,7 +73,10 @@ describe('options', function () {

it('should sort tests in alphabetical order', function (done) {
run('options/sort*', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 2);
assert.equal(res.stats.failures, 0);
Expand All @@ -84,7 +96,10 @@ describe('options', function () {

it('should run the generated test suite', function (done) {
run('options/delay.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 1);
assert.equal(res.stats.failures, 0);
Expand All @@ -98,7 +113,10 @@ describe('options', function () {

it('should throw an error if the test suite failed to run', function (done) {
run('options/delay-fail.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.failures, 1);
Expand All @@ -115,7 +133,10 @@ describe('options', function () {
it('runs specs matching a string', function (done) {
args = ['--grep', 'match'];
run('options/grep.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 2);
assert.equal(res.stats.failures, 0);
Expand All @@ -128,7 +149,10 @@ describe('options', function () {
it('with RegExp like strings(pattern follow by flag)', function (done) {
args = ['--grep', '/match/i'];
run('options/grep.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 4);
assert.equal(res.stats.failures, 0);
Expand All @@ -140,7 +164,10 @@ describe('options', function () {
it('string as pattern', function (done) {
args = ['--grep', '.*'];
run('options/grep.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 4);
assert.equal(res.stats.failures, 1);
Expand All @@ -154,7 +181,10 @@ describe('options', function () {
it('runs specs that do not match the pattern', function (done) {
args = ['--grep', 'fail', '--invert'];
run('options/grep.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 4);
assert.equal(res.stats.failures, 0);
Expand All @@ -169,7 +199,10 @@ describe('options', function () {
it('retries after a certain threshold', function (done) {
args = ['--retries', '3'];
run('options/retries.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 0);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.tests, 1);
Expand All @@ -188,15 +221,21 @@ describe('options', function () {

it('succeeds if there are only passed tests', function (done) {
run('options/forbid-only/passed.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.code, 0);
done();
});
});

it('fails if there are tests marked only', function (done) {
run('options/forbid-only/only.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.code, 1);
done();
});
Expand All @@ -210,23 +249,32 @@ describe('options', function () {

it('succeeds if there are only passed tests', function (done) {
run('options/forbid-pending/passed.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.code, 0);
done();
});
});

it('fails if there are tests marked skip', function (done) {
run('options/forbid-pending/skip.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.code, 1);
done();
});
});

it('fails if there are pending tests', function (done) {
run('options/forbid-pending/pending.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.code, 1);
done();
});
Expand Down
35 changes: 28 additions & 7 deletions test/integration/pending.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ describe('pending', function () {
describe('pending specs', function () {
it('should be created by omitting a function', function (done) {
run('pending/spec.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 1);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.failures, 0);
Expand All @@ -22,7 +25,10 @@ describe('pending', function () {
describe('in spec', function () {
it('should immediately skip the spec and run all others', function (done) {
run('pending/skip-sync-spec.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 1);
assert.equal(res.stats.passes, 1);
assert.equal(res.stats.failures, 0);
Expand All @@ -35,7 +41,10 @@ describe('pending', function () {
describe('in before', function () {
it('should skip all suite specs', function (done) {
run('pending/skip-sync-before.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 2);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.failures, 0);
Expand All @@ -48,7 +57,10 @@ describe('pending', function () {
describe('in beforeEach', function () {
it('should skip all suite specs', function (done) {
run('pending/skip-sync-beforeEach.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 2);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.failures, 0);
Expand All @@ -63,7 +75,10 @@ describe('pending', function () {
describe('in spec', function () {
it('should immediately skip the spec and run all others', function (done) {
run('pending/skip-async-spec.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 1);
assert.equal(res.stats.passes, 1);
assert.equal(res.stats.failures, 0);
Expand All @@ -76,7 +91,10 @@ describe('pending', function () {
describe('in before', function () {
it('should skip all suite specs', function (done) {
run('pending/skip-async-before.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 2);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.failures, 0);
Expand All @@ -89,7 +107,10 @@ describe('pending', function () {
describe('in beforeEach', function () {
it('should skip all suite specs', function (done) {
run('pending/skip-sync-beforeEach.fixture.js', args, function (err, res) {
assert(!err);
if (err) {
done(err);
return;
}
assert.equal(res.stats.pending, 2);
assert.equal(res.stats.passes, 0);
assert.equal(res.stats.failures, 0);
Expand Down
Loading

0 comments on commit f06f8ff

Please sign in to comment.