-
-
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
Fix Hook Test Names #3573
Fix Hook Test Names #3573
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
var assert = require('assert'); | ||
|
||
function getTitle(ctx) { | ||
return ctx.currentTest && ctx.currentTest.title; | ||
}; | ||
|
||
before(function () { | ||
assert.equal(getTitle(this), undefined); | ||
}); | ||
|
||
describe('suite A', () => { | ||
|
||
before(function () { | ||
assert.equal(getTitle(this), undefined); | ||
}); | ||
|
||
describe('suite B', () => { | ||
|
||
it('test1 B', () => {}); | ||
|
||
describe('suite C', function () { | ||
var lap = 0; | ||
|
||
before(function () { | ||
assert.equal(getTitle(this), 'test1 C'); | ||
}); | ||
beforeEach(function () { | ||
assert.equal(getTitle(this), ++lap === 1 ? 'test1 C' : 'test2 C'); | ||
}); | ||
|
||
it('test1 C', function () {}); | ||
it('test2 C', function () {}); | ||
|
||
afterEach(function () { | ||
assert.equal(getTitle(this), lap === 1 ? 'test1 C' : 'test2 C'); | ||
}); | ||
after(function () { | ||
assert.equal(getTitle(this), 'test2 C'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
after(function () { | ||
assert.equal(getTitle(this), undefined); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
describe('spec 1', function () { | ||
it('should pass', function () { }); | ||
describe('spec 2 nested - this title should be used', function () { | ||
after(function() { | ||
throw new Error('after hook nested error'); | ||
}); | ||
describe('spec 3 nested', function () { | ||
it('it nested - this title should not be used', function () { }); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
describe('spec 1', function () { | ||
it('should pass', function () { }); | ||
describe('spec nested', function () { | ||
after(function() { | ||
throw new Error('after hook nested error'); | ||
}); | ||
it('it nested - this title should be used', function () { }); | ||
}); | ||
describe('spec 2 nested', function () { | ||
it('it nested - not this title', function () { }); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
describe('spec 1', function () { | ||
it('should pass', function () { }); | ||
describe('spec 2 nested - this title should be used', function () { | ||
before(function() { | ||
throw new Error('before hook nested error'); | ||
}); | ||
describe('spec 3 nested', function () { | ||
it('it nested - this title should not be used', function () { }); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
describe('spec 1', function () { | ||
it('should pass', function () { }); | ||
describe('spec nested', function () { | ||
before(function() { | ||
throw new Error('before hook nested error'); | ||
}); | ||
it('it nested - this title should be used', function () { }); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
before(function() { | ||
throw new Error('before hook root error'); | ||
}); | ||
|
||
describe('spec 1', function () { | ||
it('should not be called', function () { }); | ||
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. Shouldn't this be an assertion? 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. The assertions are done in "hook-err.spec.js":
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ describe('suite2', function () { | |
before('before suite2', function () {}); | ||
beforeEach('beforeEach suite2', function () {}); | ||
it('test suite2', function () { | ||
runOrder.push('test suite2 - should not run'); | ||
console.log('test suite2 - should not run'); | ||
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. Shouldn't this be an assertion? 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.
|
||
}); | ||
afterEach('afterEach suite2', function () {}); | ||
after('after suite2', function () {}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ describe('suite2', function () { | |
before('before suite2', function () {}); | ||
beforeEach('beforeEach suite2', function () {}); | ||
it('test suite2', function () { | ||
runOrder.push('test suite2 - should not run'); | ||
console.log('test suite2 - should not run'); | ||
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. Shouldn't this be an assertion? 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.
|
||
}); | ||
afterEach('afterEach suite2', function () {}); | ||
after('after suite2', function () {}); | ||
|
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.
note to self: replace with constant, see #3655