【问题标题】:Stop Group Test if Assertion Failed in NightwatchJS如果 NightwatchJS 中的断言失败,则停止组测试
【发布时间】:2025-12-14 04:00:01
【问题描述】:

如果断言失败,有没有办法停止测试执行,这样其他测试组就不会被执行?

【问题讨论】:

    标签: testing nightwatch.js


    【解决方案1】:

    来自documentation

    Nightwatch.js instance has two objects containing the same methods to perform
    assertions on elements:
    
      .assert - when an assertion fails, the test ends, skipping all other assertions.
      .verify - when an assertion fails, the test logs the failure and continues with
                other assertions.
    

    所以我猜使用assert?除非你是而且那不适合你?

    【讨论】:

      【解决方案2】:

      使用 assert 将停止当前测试,但要停止整个套件,您需要在 nightwatch.json 配置文件中将设置“skip_testcases_on_fail”设置为 true。

      【讨论】: