.expect
assertions do not terminate or throw an error for individual cases where the assertion fails.
#4221
Unanswered
anupamtomar
asked this question in
Help Needed
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've encountered an issue with .expect assertions in my test cases. If a test case has three different
.expect
assertions and the first assertion fails, the test case does not fail and terminate at the point of the failed assertion. Instead, the test case passes through all the next steps or.expect
assertions without actually executing them.Additionally, I have implemented an
afterEach
hook as follows:The issue arises when a test case fails at an assertion. In such cases, the afterEach hook does not execute the browser.end() command, and the browser session is not closed. Consequently, the same browser session is used for the next test case. However, if the test case passes successfully, the afterEach hook functions correctly, closing the browser and opening a new browser session for the next test case within the same file.
Despite these issues, after all test cases in the same file are completed, the console correctly displays the errors indicating where the issues occurred.
Steps to Reproduce:
.expect
assertions.afterEach
hook is passed through without executing thebrowser.end()
command if the test case fails.Expected Behavior:
.expect
assertion.Actual Behavior:
Environment
Nightwatch.js version: v3.6.3
Node.js version: v19.9.0
Note: I have checked and got to know that in such conditions, the
.assert
method works fine. However, I prefer and would like to use.expect
over.assert
.This behaviour impacts the reliability of test results and the isolation of test cases. It would be helpful if the .expect assertions could terminate the test case immediately upon failure and ensure that the afterEach hook is executed correctly regardless of the test case outcome.
Beta Was this translation helpful? Give feedback.
All reactions