📜  QUnit-API

📅  最后修改于: 2020-12-06 10:50:24             🧑  作者: Mango


QUnit的重要API

QUnit的一些重要类别是-

Sr.No. Category Functionality
1 Assert A set of assert methods.
2 Async Control For asynchronous operations.
3 Callbacks When integrating QUnit into other tools such as CI servers, these callbacks can be used as an API to read the test results.
4 Configuration and Utilities These methods and properties are used as utility helpers and to configure QUnit. For example, to adjust the runtime behavior directly, extend the QUnit API via custom assertions, etc.
5 Test For testing operations.

类别:断言

它提供了一组断言方法。

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.

分类:异步控制

它提供了一组异步操作。

Sr.No. Methods & Description
1

async()

Instruct QUnit to wait for an asynchronous operation.

2

QUnit.asyncTest()

DEPRECATED: Add an asynchronous test to run. The test must include a call to QUnit.start().

3

QUnit.start()

PARTIALLY DEPRECATED: Start running the tests again after the testrunner was stopped. See QUnit.stop() and QUnit.config.autostart.

4

QUnit.stop()

DEPRECATED: Increase the number of QUnit.start() calls the testrunner should wait for before continuing.

5

QUnit.test()

Add a test to run.

类别:回调

将QUnit集成到CI服务器等其他工具中时,这些回调可用作API读取测试结果。

Sr.No. Methods & Description
1

QUnit.begin()

Register a callback to fire whenever the test suite begins.

2

QUnit.done()

Register a callback to fire whenever the test suite ends.

3

QUnit.log()

Register a callback to fire whenever an assertion completes.

4

QUnit.moduleDone()

Register a callback to fire whenever a module ends.

5

QUnit.moduleStart()

Register a callback to fire whenever a module begins.

6

QUnit.testDone()

Register a callback to fire whenever a test ends.

7

QUnit.testStart()

Register a callback to fire whenever a test begins.

类别:配置和实用程序

这些方法和属性用作实用程序帮助程序并配置QUnit。例如,要直接调整运行时行为,请通过自定义断言等扩展QUnit API。

Sr.No. Methods & Description
1

QUnit.assert

Namespace for QUnit assertions.

2

QUnit.config

Configuration for QUnit.

3

QUnit.dump.parse()

Advanced and extensible data dumping for JavaScript.

4

QUnit.extend()

Copy the properties defined by the mixin object into the target object.

5

QUnit.init()

DEPRECATED: Re-initialize the test runner.

6

QUnit.push()

DEPRECATED: Report the result of a custom assertion.

7

QUnit.reset()

DEPRECATED: Reset the test fixture in the DOM.

8

QUnit.stack()

Returns a single line string representing the stacktrace (call stack).

分类:测试

它提供了一组测试操作。

Sr.No. Methods & Description
1

QUnit.assert

Namespace for QUnit assertions.

2

QUnit.asyncTest()

DEPRECATED: Add an asynchronous test to run. The test must include a call to QUnit.start().

3

QUnit.module()

Group related tests under a single label.

4

QUnit.only()

Adds a test to exclusively run, preventing all other tests from running.

5

QUnit.skip()

Adds a test like object to be skipped.

6

QUnit.test()

Adds a test to run.