Skip to content
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

Throw Error When Using Nested It Specs #4039

Merged
merged 4 commits into from
Aug 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/jest-jasmine2/src/jasmine/Env.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,18 @@ module.exports = function(j$) {
if (currentDeclarationSuite.markedPending) {
spec.pend();
}

// When a test is defined inside another, jasmine will not run it.
// This check throws an error to warn the user about the edge-case.
if (currentSpec !== null) {
throw new Error(
'Tests cannot be nested. Test `' +
spec.description +
'` cannot run because it is nested within `' +
currentSpec.description +
'`.',
);
}
currentDeclarationSuite.addChild(spec);
return spec;
};
Expand Down