How to get Mocha to fail a test

后端 未结 4 557
遇见更好的自我
遇见更好的自我 2021-02-02 07:15

I have the following test:

it.only(\'validation should fail\', function(done) {
    var body = {
        title: \"dffdasfsdfsdafddfsadsa\",
        description:          


        
4条回答
  •  感情败类
    2021-02-02 08:06

    You can call assert.fail:

    it("should return empty set of tags", function()
    {
        assert.fail("actual", "expected", "Error message");
    });
    

    Also, Mocha considers the test has failed if you call the done() function with a parameter.

    For example:

    it("should return empty set of tags", function(done)
    {
        done(new Error("Some error message here"));
    });
    

    Though the first one looks clearer to me.

提交回复
热议问题