From ae779ac92ece7e978487da77af5eaa48b9b94821 Mon Sep 17 00:00:00 2001 From: Priyansh Garg Date: Wed, 31 Jan 2024 20:31:18 +0530 Subject: [PATCH] Warn about two `describe()`s in a single testsuite. (#4011) --- lib/testsuite/context.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/testsuite/context.js b/lib/testsuite/context.js index e78234e5aa..b32f9f9cc5 100644 --- a/lib/testsuite/context.js +++ b/lib/testsuite/context.js @@ -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) {