How to get Mocha to fail a test

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)