📅  最后修改于: 2020-12-06 10:50:45             🧑  作者: Mango
所有的断言都在断言类别中。
此类提供了一组断言方法,可用于编写测试。仅记录失败的断言。
Sr.No. | Methods & Description |
---|---|
1 |
async() Instruct QUnit to wait for an asynchronous operation. |
2 |
deepEqual() A deep recursive comparison, working on primitive types, arrays, objects, regular expressions, dates, and functions. |
3 |
equal() A non-strict comparison, roughly equivalent to JUnit’s assertEquals. |
4 |
expect() Specify how many assertions are expected to run within a test. |
5 |
notDeepEqual() An inverted deep recursive comparison, working on primitive types, arrays, objects, regular expressions, dates, and functions. |
6 |
notEqual() A non-strict comparison, checking for inequality. |
7 |
notOk() A boolean check, inverse of ok() and CommonJS’s assert.ok(), and equivalent to JUnit’s assertFalse(). Passes if the first argument is false. |
8 |
notPropEqual() A strict comparison of an object’s own properties, checking for inequality. |
9 |
notStrictEqual() A strict comparison, checking for inequality. |
10 |
ok() A boolean check, equivalent to CommonJS’s assert.ok() and JUnit’s assertTrue(). Passes if the first argument is true. |
11 |
propEqual() A strict type and value comparison of an object’s own properties. |
12 |
push() Report the result of a custom assertion. |
13 |
strictEqual() A strict type and value comparison. |
14 |
throws() Test if a callback throws an exception, and optionally compare the thrown error. |
让我们尝试在一个示例中涵盖上述大多数方法。
QUnit basic example
您应该看到以下结果-