javascript - 是否有类似 jasmine `toNotContain` 的测试验收标准?

标签 javascript unit-testing testing jasmine karma-runner

Jasmin 附带许多函数来检查验证规范和测试的预期值。

还有没有

getJasmineRequireObj().toContain = function() { ... };

有点像

getJasmineRequireObj().toNotContain = function() { ... };

?

If not, how to add an extension or plugin to deliver this feature also to our community of developers?

最佳答案

根据文档,您可以使用not:

getJasmineRequireObj().not.toContain

这个例子来自here :

describe("The 'toBe' matcher compares with ===", function() {

Matchers

Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.

    it("and has a positive case", function() {
        expect(true).toBe(true);
    });

Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.

    it("and can have a negative case", function() {
        expect(false).not.toBe(true);
    });
});

关于javascript - 是否有类似 jasmine `toNotContain` 的测试验收标准?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37483566/

相关文章:

node.js - 如何为用户需要登录的网页编写单元测试

testing - 基于规范或需求的测试的覆盖率指标是什么?

javascript - react ( Facebook ): managed state of controlled checkboxes

java - 文件读取和可测试代码

.net - 使用/clr :safe to enable unit testing? 编译 C++ 项目有什么缺点

testing - 访问当前夹具的名称并在运行时进行测试

testing - 使用 Cucumberish 在 XCUITest 设置中重置应用程序

javascript - 您可以在 JS fetch() 'body' 字段中使用 JSON.stringify 或 URL 格式吗?

javascript - 加载内容和 css 异步时闪烁/缓慢的 css

javascript - 内联 CSS 样式未渲染 [以前为 : Component is not rendering its elements - react]