-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue/2819 - Fix / Clarify this.skip behavior in before hooks (#3225)
* Fix Issue 2819 - this.skip should skip tests in nested suites. Side Effects: - Fixed typo in beforeEach async pending test that was using sync fixture. - Fixed beforeEach async pending test to reflect current behavior. * fixup! Fix Issue 2819 - this.skip should skip tests in nested suites. * docs: Add more details regarding suite-level skip. * test: Update error messages in before hook integration tests. * test: Remove timeout delays from pending tests. * test: Consistently throw errors in pending test fixtures.
- Loading branch information
Showing
13 changed files
with
392 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
test/integration/fixtures/pending/skip-async-before-hooks.fixture.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use strict'; | ||
|
||
describe('outer suite', function () { | ||
|
||
before(function () { | ||
console.log('outer before'); | ||
}); | ||
|
||
it('should run this test', function () { }); | ||
|
||
describe('inner suite', function () { | ||
|
||
before(function (done) { | ||
console.log('inner before'); | ||
var self = this; | ||
setTimeout(function () { | ||
self.skip(); | ||
done(); | ||
}, 0); | ||
}); | ||
|
||
beforeEach(function () { | ||
throw new Error('beforeEach should not run'); | ||
}); | ||
|
||
afterEach(function () { | ||
throw new Error('afterEach should not run'); | ||
}); | ||
|
||
it('should not run this test', function () { | ||
throw new Error('inner suite test should not run'); | ||
}); | ||
|
||
after(function () { | ||
console.log('inner after'); | ||
}); | ||
|
||
describe('skipped suite', function () { | ||
before(function () { | ||
console.log('skipped before'); | ||
}); | ||
|
||
it('should not run this test', function () { | ||
throw new Error('skipped suite test should not run'); | ||
}); | ||
|
||
after(function () { | ||
console.log('skipped after'); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
it('should run this test', function () { }); | ||
|
||
after(function () { | ||
console.log('outer after'); | ||
}); | ||
|
||
}); |
41 changes: 41 additions & 0 deletions
41
test/integration/fixtures/pending/skip-async-before-nested.fixture.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
describe('skip in before with nested describes', function () { | ||
before(function (done) { | ||
var self = this; | ||
setTimeout(function () { | ||
self.skip(); | ||
done(); | ||
}, 0); | ||
}); | ||
|
||
it('should never run this test', function () { | ||
throw new Error('never run this test'); | ||
}); | ||
|
||
describe('nested describe', function () { | ||
before(function () { | ||
throw new Error('first level before should not run'); | ||
}); | ||
|
||
it('should never run this test', function () { | ||
throw new Error('never run this test'); | ||
}); | ||
|
||
after(function () { | ||
throw new Error('first level after should not run'); | ||
}); | ||
|
||
describe('nested again', function () { | ||
before(function () { | ||
throw new Error('second level before should not run'); | ||
}); | ||
|
||
it('should never run this test', function () { | ||
throw new Error('never run this test'); | ||
}); | ||
|
||
after(function () { | ||
throw new Error('second level after should not run'); | ||
}); | ||
}); | ||
}); | ||
}); |
29 changes: 17 additions & 12 deletions
29
test/integration/fixtures/pending/skip-async-before.fixture.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
'use strict'; | ||
|
||
describe('skip in before', function () { | ||
before(function (done) { | ||
var self = this; | ||
setTimeout(function () { | ||
self.skip(); | ||
}, 50); | ||
}); | ||
describe('outer describe', function () { | ||
it('should run this test', function () {}); | ||
|
||
it('should never run this test', function () { | ||
throw new Error('never thrown'); | ||
}); | ||
describe('skip in before', function () { | ||
before(function (done) { | ||
var self = this; | ||
setTimeout(function () { | ||
self.skip(); | ||
}, 0); | ||
}); | ||
|
||
it('should never run this test', function () { | ||
throw new Error('never thrown'); | ||
it('should never run this test', function () { | ||
throw new Error('never run this test'); | ||
}); | ||
it('should never run this test', function () { | ||
throw new Error('never run this test'); | ||
}); | ||
}); | ||
|
||
it('should run this test', function () {}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
test/integration/fixtures/pending/skip-sync-before-hooks.fixture.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
describe('outer suite', function () { | ||
|
||
before(function () { | ||
console.log('outer before'); | ||
}); | ||
|
||
it('should run this test', function () { }); | ||
|
||
describe('inner suite', function () { | ||
before(function () { | ||
this.skip(); | ||
}); | ||
|
||
before(function () { | ||
console.log('inner before'); | ||
}); | ||
|
||
beforeEach(function () { | ||
throw new Error('beforeEach should not run'); | ||
}); | ||
|
||
afterEach(function () { | ||
throw new Error('afterEach should not run'); | ||
}); | ||
|
||
after(function () { | ||
console.log('inner after'); | ||
}); | ||
|
||
it('should never run this test', function () { | ||
throw new Error('inner suite test should not run'); | ||
}); | ||
|
||
describe('skipped suite', function () { | ||
before(function () { | ||
console.log('skipped before'); | ||
}); | ||
|
||
it('should never run this test', function () { | ||
throw new Error('skipped suite test should not run'); | ||
}); | ||
|
||
after(function () { | ||
console.log('skipped after'); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should run this test', function () { }); | ||
|
||
after(function () { | ||
console.log('outer after'); | ||
}) | ||
|
||
}); |
39 changes: 39 additions & 0 deletions
39
test/integration/fixtures/pending/skip-sync-before-nested.fixture.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
|
||
describe('skip in before with nested describes', function () { | ||
before(function () { | ||
this.skip(); | ||
}); | ||
|
||
it('should never run this test', function () { | ||
throw new Error('never run this test'); | ||
}); | ||
|
||
describe('nested describe', function () { | ||
before(function () { | ||
throw new Error('first level before should not run'); | ||
}); | ||
|
||
it('should never run this test', function () { | ||
throw new Error('never run this test'); | ||
}); | ||
|
||
after(function () { | ||
throw new Error('first level after should not run'); | ||
}); | ||
|
||
describe('nested again', function () { | ||
before(function () { | ||
throw new Error('second level before should not run'); | ||
}); | ||
|
||
it('should never run this test', function () { | ||
throw new Error('never run this test'); | ||
}); | ||
|
||
after(function () { | ||
throw new Error('second level after should not run'); | ||
}); | ||
}); | ||
}); | ||
}); |
23 changes: 14 additions & 9 deletions
23
test/integration/fixtures/pending/skip-sync-before.fixture.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
'use strict'; | ||
|
||
describe('skip in before', function () { | ||
before(function () { | ||
this.skip(); | ||
}); | ||
describe('outer describe', function () { | ||
it('should run this test', function () {}); | ||
|
||
it('should never run this test', function () { | ||
throw new Error('never thrown'); | ||
}); | ||
describe('skip in before', function () { | ||
before(function () { | ||
this.skip(); | ||
}); | ||
|
||
it('should never run this test', function () { | ||
throw new Error('never thrown'); | ||
it('should never run this test', function () { | ||
throw new Error('never run this test'); | ||
}); | ||
it('should never run this test', function () { | ||
throw new Error('never run this test'); | ||
}); | ||
}); | ||
|
||
it('should run this test', function () {}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.