简体   繁体   中英

Expect a failing Jasmine matcher

Is there a way to expect a failing Jasmine matcher in a method? The following code shows what I'm trying to do:

function test() {
    expect(true).toBe(false);
};

describe("A suite", function() {
  it("contains spec with an expectation", function() {   
    expect(function() {
        test();
    }).toThrow();
  });
});

I would like to see this spec marked as "ok". Is there a way to do that?

如果您查看Jasmine如何测试其自己的Matchers,您也许可以按照相同的方式遵循其拥有独立实例的方法:一个是测试运行程序,另一个是被测试运行程序。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM