gpt4 book ai didi

jasmine - 第一次期望失败后停止 Jasmine 测试

转载 作者:行者123 更新时间:2023-12-02 04:36:43 28 4
gpt4 key购买 nike

我熟悉 python 单元测试测试,如果断言失败,该测试将被标记为“失败”,并继续进行其他测试。另一方面,即使其中一个失败, Jasmine 也会继续完成所有期望。如何让 Jasmine 在第一个期望失败后停止处理测试?

it ("shouldn't need to test other expects if the first fails", function() {
expect(array.length).toBe(1);

// don't need to check this if the first failed.
expect(array[0]).toBe("foo");
});

难道是我想错了?我进行了一些带有大量 expect 的测试,当只有第一个确实错误时,显示所有堆栈跟踪似乎是一种浪费。

最佳答案

对于当时最新版本的 Jasmine ( v2.0.0 ),@Gregg 的答案是正确的。

但是,从那时起,这个新功能就是 addedv2.3.0 :

Allow user to stop a specs execution when an expectation fails (Fixes #577)

通过将 throwFailures=true 添加到运行器页面的查询字符串来激活它,例如:

http://localhost:8000/?throwFailures=true

关于jasmine - 第一次期望失败后停止 Jasmine 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22119193/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com