Interface QUnitStatic

Hierarchy

Index

Properties

Methods

Properties

public assert: any

public config: Config

QUnit has a bunch of internal configuration defaults, some of which are useful to override. Check the description for each option for details.

public current_testEnvironment: any

public jsDump: any

public raises: any

Methods

public asyncTest(name: string, expected: number, test: () => any): any

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

For testing asynchronous code, asyncTest will automatically stop the test runner and wait for your code to call start() to continue.

Parameters

  • name: string

    Title of unit being tested

  • expected: number

    Number of assertions in this test

  • test: () => any

    Function to close over assertions

Returns

any

public asyncTest(name: string, test: () => any): any

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

For testing asynchronous code, asyncTest will automatically stop the test runner and wait for your code to call start() to continue.

Parameters

  • name: string

    Title of unit being tested

  • test: () => any

    Function to close over assertions

Returns

any

public begin(callback: () => any): any

Register a callback to fire whenever the test suite begins.

QUnit.begin() is called once before running any tests. (a better would've been QUnit.start, but thats already in use elsewhere and can't be changed.)

Parameters

  • callback: () => any

    Callback to execute

Returns

any

public deepEqual(actual: any, expected: any, message?: string): any

A deep recursive comparison assertion, working on primitive types, arrays, objects, regular expressions, dates and functions.

The deepEqual() assertion can be used just like equal() when comparing the value of objects, such that { key: value } is equal to { key: value }. For non-scalar values, identity will be disregarded by deepEqual.

Parameters

  • actual: any

    Object or Expression being tested

  • expected: any

    Known comparison value

  • message?: string optional

    A short description of the assertion

Returns

any

public done(callback: (details: DoneCallbackObject) => any): any

Register a callback to fire whenever the test suite ends.

Parameters

  • callback: (details: DoneCallbackObject) => any

    Callback to execute.

Returns

any

public equal(actual: any, expected: any, message?: string): any

A non-strict comparison assertion, roughly equivalent to JUnit assertEquals.

The equal assertion uses the simple comparison operator (==) to compare the actual and expected arguments. When they are equal, the assertion passes: any; otherwise, it fails. When it fails, both actual and expected values are displayed in the test result, in addition to a given message.

Parameters

  • actual: any

    Expression being tested

  • expected: any

    Known comparison value

  • message?: string optional

    A short description of the assertion

Returns

any

public equiv(a: any, b: any): any

https://github.com/jquery/qunit/blob/master/qunit/qunit.js#L1568

Parameters

  • a: any
  • b: any

Returns

any

public expect(amount: number): any

Specify how many assertions are expected to run within a test.

To ensure that an explicit number of assertions are run within any test, use expect( number ) to register an expected count. If the number of assertions run does not match the expected count, the test will fail.

Parameters

  • amount: number

    Number of assertions in this test.

Returns

any

public log(callback: (details: LogCallbackObject) => any): any

Register a callback to fire whenever an assertion completes.

This is one of several callbacks QUnit provides. Its intended for integration scenarios like PhantomJS or Jenkins. The properties of the details argument are listed below as options.

Parameters

  • callback: (details: LogCallbackObject) => any

    Callback to execute.

Returns

any

public module(name: string, lifecycle?: LifecycleObject): any

Group related tests under a single label.

All tests that occur after a call to module() will be grouped into that module. The test names will all be preceded by the module name in the test results. You can then use that module name to select tests to run.

Parameters

  • name: string

    Label for this group of tests

  • lifecycle?: LifecycleObject optional

    Callbacks to run before and after each test

Returns

any

public moduleDone(callback: (details: ModuleDoneCallbackObject) => any): any

Register a callback to fire whenever a module ends.

Parameters

  • callback: (details: ModuleDoneCallbackObject) => any

    Callback to execute.

Returns

any

public moduleStart(callback: (details: ModuleStartCallbackObject) => any): any

Register a callback to fire whenever a module begins.

Parameters

  • callback: (details: ModuleStartCallbackObject) => any

    Callback to execute.

Returns

any

public notDeepEqual(actual: any, expected: any, message?: string): any

An inverted deep recursive comparison assertion, working on primitive types, arrays, objects, regular expressions, dates and functions.

The notDeepEqual() assertion can be used just like equal() when comparing the value of objects, such that { key: value } is equal to { key: value }. For non-scalar values, identity will be disregarded by notDeepEqual.

Parameters

  • actual: any

    Object or Expression being tested

  • expected: any

    Known comparison value

  • message?: string optional

    A short description of the assertion

Returns

any

public notEqual(actual: any, expected: any, message?: string): any

A non-strict comparison assertion, checking for inequality.

The notEqual assertion uses the simple inverted comparison operator (!=) to compare the actual and expected arguments. When they aren't equal, the assertion passes: any; otherwise, it fails. When it fails, both actual and expected values are displayed in the test result, in addition to a given message.

Parameters

  • actual: any

    Expression being tested

  • expected: any

    Known comparison value

  • message?: string optional

    A short description of the assertion

Returns

any

public notPropEqual(actual: any, expected: any, message?: string): any

Parameters

  • actual: any
  • expected: any
  • message?: string optional

Returns

any

public notStrictEqual(actual: any, expected: any, message?: string): any

A non-strict comparison assertion, checking for inequality.

The notStrictEqual assertion uses the strict inverted comparison operator (!==) to compare the actual and expected arguments. When they aren't equal, the assertion passes: any; otherwise, it fails. When it fails, both actual and expected values are displayed in the test result, in addition to a given message.

Parameters

  • actual: any

    Expression being tested

  • expected: any

    Known comparison value

  • message?: string optional

    A short description of the assertion

Returns

any

public ok(state: any, message?: string): any

A boolean assertion, equivalent to CommonJS’s assert.ok() and JUnit’s assertTrue(). Passes if the first argument is truthy.

The most basic assertion in QUnit, ok() requires just one argument. If the argument evaluates to true, the assertion passes; otherwise, it fails. If a second message argument is provided, it will be displayed in place of the result.

Parameters

  • state: any

    Expression being tested

  • message?: string optional

    A short description of the assertion

Returns

any

public propEqual(actual: any, expected: any, message?: string): any

Parameters

  • actual: any
  • expected: any
  • message?: string optional

Returns

any

public push(result: any, actual: any, expected: any, message: string): any

https://github.com/jquery/qunit/blob/master/qunit/qunit.js#L897

Parameters

  • result: any
  • actual: any
  • expected: any
  • message: string

Returns

any

public reset(): any

https://github.com/jquery/qunit/blob/master/qunit/qunit.js#L839

Returns

any

public start(decrement?: number): any

Start running tests again after the testrunner was stopped. See stop().

When your async test has multiple exit points, call start() for the corresponding number of stop() increments.

Parameters

  • decrement?: number optional

    Optional argument to merge multiple start() calls into one. Use with multiple corrsponding stop() calls.

Returns

any

public stop(increment?: number): any

Stop the testrunner to wait for async tests to run. Call start() to continue.

When your async test has multiple exit points, call stop() with the increment argument, corresponding to the number of start() calls you need.

On Blackberry 5.0, window.stop is a native read-only function. If you deal with that browser, use QUnit.stop() instead, which will work anywhere.

Parameters

  • increment?: number optional

Returns

any

public strictEqual(actual: any, expected: any, message?: string): any

A strict type and value comparison assertion.

The strictEqual() assertion provides the most rigid comparison of type and value with the strict equality operator (===)

Parameters

  • actual: any

    Expression being tested

  • expected: any

    Known comparison value

  • message?: string optional

    A short description of the assertion

Returns

any

public test(title: string, expected: number, test: (assert: QUnitAssert) => any): any

Add a test to run.

When testing the most common, synchronous code, use test(). The assert argument to the callback contains all of QUnit's assertion methods. If you are avoiding using any of QUnit's globals, you can use the assert argument instead.

Parameters

  • title: string

    Title of unit being tested

  • expected: number

    Number of assertions in this test

  • test: (assert: QUnitAssert) => any

    Function to close over assertions

Returns

any

public test(title: string, test: (assert: QUnitAssert) => any): any

Parameters

  • title: string

    Title of unit being tested

  • test: (assert: QUnitAssert) => any

    Function to close over assertions

Returns

any

public testDone(callback: (details: TestDoneCallbackObject) => any): any

Register a callback to fire whenever a test ends.

Parameters

  • callback: (details: TestDoneCallbackObject) => any

    Callback to execute.

Returns

any

public testStart(callback: (details: TestStartCallbackObject) => any): any

Register a callback to fire whenever a test begins.

Parameters

  • callback: (details: TestStartCallbackObject) => any

    Callback to execute.

Returns

any

public throws(block: () => any, expected: any, message?: string): any

Assertion to test if a callback throws an exception when run.

When testing code that is expected to throw an exception based on a specific set of circumstances, use throws() to catch the error object for testing and comparison.

Parameters

  • block: () => any

    Function to execute

  • expected: any

    Error Object to compare

  • message?: string optional

    A short description of the assertion

Returns

any

public throws(block: () => any, message?: string): any

Parameters

  • block: () => any

    Function to execute

  • message?: string optional

    A short description of the assertion

Returns

any