Skip to content

Commit

Permalink
additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Feb 12, 2020
1 parent aa81f6c commit e4f423b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
8 changes: 8 additions & 0 deletions test/integration/fixtures/retries/early-pass.fixture.js
@@ -1,13 +1,21 @@
'use strict';
const assert = require('assert');

describe('retries', function () {
this.retries(1);
var times = 0;
var self = this;

it('should pass after 1 retry', function () {
times++;
if (times !== 2) {
throw new Error('retry error ' + times);
}
});

it('check for updated `suite.tests`', function() {
assert.equal(self.tests[0]._currentRetry, 1);
assert.ok(self.tests[0]._retriedTest);
assert.equal(self.tests[0].state, 'passed');
})
});
22 changes: 10 additions & 12 deletions test/integration/retries.spec.js
Expand Up @@ -2,6 +2,7 @@

var assert = require('assert');
var helpers = require('./helpers');
var runJSON = helpers.runMochaJSON;
var args = [];
var bang = require('../../lib/reporters/base').symbols.bang;

Expand Down Expand Up @@ -59,25 +60,22 @@ describe('retries', function() {
});

it('should exit early if test passes', function(done) {
helpers.runMochaJSON('retries/early-pass.fixture.js', args, function(
err,
res
) {
runJSON('retries/early-pass.fixture.js', args, function(err, res) {
if (err) {
done(err);
return;
return done(err);
}
assert.strictEqual(res.stats.passes, 1);
assert.strictEqual(res.stats.failures, 0);
assert.strictEqual(res.tests[0].currentRetry, 1);
assert.strictEqual(res.stats.tests, 1);
assert.strictEqual(res.code, 0);

expect(res, 'to have passed')
.and('to have passed test count', 2)
.and('to have failed test count', 0)
.and('to have retried test', 'should pass after 1 retry', 1);

done();
});
});

it('should let test override', function(done) {
helpers.runMochaJSON('retries/nested.fixture.js', args, function(err, res) {
runJSON('retries/nested.fixture.js', args, function(err, res) {
if (err) {
done(err);
return;
Expand Down
6 changes: 6 additions & 0 deletions test/unit/test.spec.js
Expand Up @@ -41,6 +41,12 @@ describe('Test', function() {
expect(this._test.clone().currentRetry(), 'to be', 1);
});

it('should add/keep the retriedTest value', function() {
var clone1 = this._test.clone();
expect(clone1._retriedTest, 'to be', this._test);
expect(clone1.clone()._retriedTest, 'to be', this._test);
});

it('should copy the globals value', function() {
expect(this._test.clone().globals(), 'not to be empty');
});
Expand Down

0 comments on commit e4f423b

Please sign in to comment.