QUnit, assert not OK?

后端 未结 5 1103
南方客
南方客 2021-01-20 04:26

Sorry if this is obvious, but is there a notOK or equivalent function in QUnit, if we want to assert that a method returns false?

I can\'t see a way to negate OK in

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-20 04:55

    If this is something you really, really want, you can add it with QUnit.extend():

    QUnit.extend(QUnit.assert, {
        notOk: function (result, message) {
            message = message || (!result ? "okay" : "failed, expected argument to be falsey, was: " +
            QUnit.dump.parse(result));
            QUnit.push(!result, result, false, message);
        },
    });
    

提交回复
热议问题