Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Latest commit

 

History

History
80 lines (56 loc) · 1.94 KB

filter.md

File metadata and controls

80 lines (56 loc) · 1.94 KB
layout title excerpt groups redirect_from version_added
page-api
QUnit.config.filter
Select tests to run based on a substring or pattern match.
config
/config/filter/
1.0.0

Select tests to 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.

QUnit only runs tests of which the module name or test name are a case-insensitive substring match for the filter string. You can invert the filter by prefixing an exclamation mark (!) to the string, in which case we skip the matched tests, and run the tests that don't match the filter.

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

While substring filters are always case-insensitive, a regular expression is case-sensitive by default.

See also:

Examples

Substring filter

The below matches FooBar and foo > bar, because string matching is case-insensitive.

QUnit.config.filter = 'foo';

As inversed filter, the below skips FooBar and foo > bar, but runs Bar and bar > sub.

QUnit.config.filter = '!foo';

Regular expression filter

The below matches foo but not Foo, because regexes are case-sensitive by default.

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

The below matches both foo and Foo.

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

The below skips both foo and Foo.

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

The below matches foo, foo > sub, and foo.sub, but skips bar, bar.foo, and FooBar.

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