Skip to content

Commit

Permalink
Warn about two describe()s in a single testsuite.
Browse files Browse the repository at this point in the history
  • Loading branch information
garg3133 committed Jan 31, 2024
1 parent 2e301b5 commit 51e1fcf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/testsuite/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,14 @@ class Context extends EventEmitter {
* @param {Boolean=false} [runOnly] If the runner should run only this testsuite
*/
setDescribeContext({describeTitle, describeInstance, runOnly}) {
if (this.__testSuiteName && !describeInstance) {
throw new Error('There is already a top-level "describe"/"context" declaration in this testsuite.');
// if `setDescribeContext` is called twice for the same test suite,
// that would mean that there are two `describe()`s in same test suite.
if (this.__testSuiteName && describeInstance) {
// eslint-disable-next-line no-console
console.warn(
'Nightwatch does not support more than one "describe" declarations in a single testsuite.' +
' Using this might give unexpected results.'
);
}

if (runOnly) {
Expand Down

0 comments on commit 51e1fcf

Please sign in to comment.