QUnit.config.filter

version added: 1.0.0

Description

Decide selectively which tests should run based on a substring or pattern match.

type string or undefined
default undefined

This option is available as CLI option, as control in the HTML Reporter, and supported as URL query parameter.

Only run tests of which the module name or test name have a case-insensitive substring match for the provided string. You can inverse the filter by prefixing a bang character (!) to the string, which will exclude the matched tests, thus only running tests that don’t contain the string.

You can also match via a regular expression by setting the filter to a regular expression literal in string form, encloses by slashes, such as /(this|that)/.

While substring filters are always case-insensitive, a regular expression is only insensitive when passing the /i flag.

See also:

Examples

Substring filter

The below matches QUnit.module( "FooBar" ) and QUnit.test( "createFooBar" ).

QUnit.config.filter = 'foo';

As inverted filter, the below would skip QUnit.module( "FooBar" ) and QUnit.test( "createFooBar" ), but match QUnit.module( "Bar" ) and QUnit.test( "createBar" ).

QUnit.config.filter = '!foo';

Regular expression filter

The below would match QUnit.test( "foo" ), but not QUnit.test( "Foo" ).

QUnit.config.filter = '/foo/';

The below would both match QUnit.test( "foo" ) and QUnit.test( "Foo" ).

QUnit.config.filter = '/foo/i';

The below would exclude QUnit.test( "foo" ) and QUnit.test( "Foo" ).

QUnit.config.filter = '!/foo/i';