-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: detect illegally nested tests (#4525) #5395
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
Open
mmorearty
wants to merge
5
commits into
mochajs:main
Choose a base branch
from
mmorearty:feature-nested-test-detection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b5d8eea
feat: detect illegally nested tests (#4525)
mmorearty a710267
Change to not use a global variable
mmorearty 0692d3e
Remove trailing whitespace
mmorearty 554fb1f
Merge common code
mmorearty efb05c8
Update lib/interfaces/common.js
mmorearty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
37 changes: 37 additions & 0 deletions
37
test/integration/fixtures/nested-tests/bdd-async-nested.fixture.js
This file contains hidden or 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,37 @@ | ||
| 'use strict'; | ||
|
|
||
| // BDD async nested test fixtures - should fail with nested test errors | ||
| describe('Async Nested Tests', function() { | ||
| it('sync nested test', function() { | ||
| it('nested in sync', function() { | ||
| // Should fail immediately | ||
| }); | ||
| }); | ||
|
|
||
| it('callback nested test', function(done) { | ||
| setTimeout(function() { | ||
| it('nested in callback', function() { | ||
| // Should fail with uncaught error | ||
| }); | ||
| done(); | ||
| }, 10); | ||
| }); | ||
|
|
||
| it('promise nested test', function() { | ||
| return new Promise(function(resolve) { | ||
| setTimeout(function() { | ||
| it('nested in promise', function() { | ||
| // Should fail with uncaught error | ||
| }); | ||
| resolve(); | ||
| }, 10); | ||
| }); | ||
| }); | ||
|
|
||
| it('async/await nested test', async function() { | ||
| await new Promise(resolve => setTimeout(resolve, 10)); | ||
| it('nested in async', function() { | ||
| // Should fail | ||
| }); | ||
| }); | ||
| }); |
15 changes: 15 additions & 0 deletions
15
test/integration/fixtures/nested-tests/bdd-hook-nested.fixture.js
This file contains hidden or 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,15 @@ | ||
| 'use strict'; | ||
|
|
||
| // BDD hook nested test fixture - should fail with nested test error | ||
| describe('Hook Nested Test Suite', function() { | ||
| before(function() { | ||
| // This should fail due to nested test inside hook | ||
| it('nested test in before hook', function() { | ||
| // This nested test should cause an error | ||
| }); | ||
| }); | ||
|
|
||
| it('normal test', function() { | ||
| // This should pass if no hook error | ||
| }); | ||
| }); |
19 changes: 19 additions & 0 deletions
19
test/integration/fixtures/nested-tests/bdd-nested.fixture.js
This file contains hidden or 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,19 @@ | ||
| 'use strict'; | ||
|
|
||
| // BDD nested test fixture - should fail with nested test error | ||
| describe('Parent Suite', function() { | ||
| it('normal test', function() { | ||
| // This should pass | ||
| }); | ||
|
|
||
| it('outer test with nested test', function() { | ||
| // This should fail due to nested test | ||
| it('inner nested test', function() { | ||
| // This nested test should cause an error | ||
| }); | ||
| }); | ||
|
|
||
| it('another normal test', function() { | ||
| // This should not run due to previous failure | ||
| }); | ||
| }); |
19 changes: 19 additions & 0 deletions
19
test/integration/fixtures/nested-tests/tdd-nested.fixture.js
This file contains hidden or 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,19 @@ | ||
| 'use strict'; | ||
|
|
||
| // TDD nested test fixture - should fail with nested test error | ||
| suite('Parent Suite', function() { | ||
| test('normal test', function() { | ||
| // This should pass | ||
| }); | ||
|
|
||
| test('outer test with nested test', function() { | ||
| // This should fail due to nested test | ||
| test('inner nested test', function() { | ||
| // This nested test should cause an error | ||
| }); | ||
| }); | ||
|
|
||
| test('another normal test', function() { | ||
| // This should not run due to previous failure | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.