-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to retry failed test from test context for #1773 #1989
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -529,8 +529,16 @@ Runner.prototype.runTests = function(suite, fn) { | |
test = self.test; | ||
|
||
if (err) { | ||
var retry = test.currentRetry(); | ||
if (err instanceof Pending) { | ||
self.emit('pending', test); | ||
} else if (retry < test.retries()) { | ||
test.currentRetry(retry + 1); | ||
tests.unshift(test); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to add more tests to the test suite? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. up to the collaborators I guess. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given |
||
|
||
// Early return + hook trigger so that it doesn't | ||
// increment the count wrong | ||
return self.hookUp('afterEach', next); | ||
} else { | ||
self.fail(test, err); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
describe('retries', function() { | ||
it('should fail', function () { | ||
throw new Error('retry failure'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
describe('retries', function() { | ||
this.retries(1); | ||
var times = 0; | ||
|
||
it('should pass after 1 retry', function() { | ||
times++; | ||
if (times !== 2) { | ||
throw new Error('retry error ' + times); | ||
} | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
describe('retries', function() { | ||
var times = 0; | ||
before(function () { | ||
console.log('before'); | ||
}); | ||
|
||
after(function () { | ||
console.log('after'); | ||
}); | ||
|
||
beforeEach(function() { | ||
console.log('before each', times); | ||
}); | ||
|
||
afterEach(function () { | ||
console.log('after each', times); | ||
}); | ||
|
||
it('should allow override and run appropriate hooks', function(){ | ||
this.retries(4); | ||
console.log('TEST', times); | ||
times++; | ||
throw new Error('retry error'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
describe('retries', function() { | ||
this.retries(3); | ||
describe('nested', function () { | ||
it('should fail after only 1 retry', function(){ | ||
this.retries(1); | ||
throw new Error('retry error'); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate annotations here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I fixed that, but turns out there're actually a bunch of other methods w/ dupe annotations (
timeout
,enableTimeout
...)