Metadata and Filtering

Users can embed custom metadata into fixture and test definitions. Custom reporters may then include this metadata in run reports. Additionally, you can filter the contents of your test suite by metadata.

Define Fixture Metadata

The fixture.meta method defines fixture metadata.

fixture `My fixture`
    .meta('fixtureID', 'f-0001')
    .meta({ author: 'John', creationDate: '05/03/2018' });

Define Test Metadata

The test.meta method defines test metadata.

    .meta('testID', 't-0005')
    .meta({ severity: 'critical', testedAPIVersion: '1.0' })
    ('MyTest', async t => { /* ... */});

Include Metadata in Run Reports

Ready-made reporters do not output test metadata. Create a custom reporter to include metadata in run reports. Custom reporters can access metadata with reportFixtureStart and reportTestDone methods.

Filter Tests and Fixtures by metadata

You can filter the contents of your test suite by metadata and only run a selection of tests or fixtures with specific metadata. Read the Skip Tests and Fixtures guide to learn how to skip tests and fixtures one-by-one.

  • If you launch TestCafe with a shell command, define the filtering criteria with the --test-meta and --fixture-meta command line options.
  • If you use the Runner API, define the testMeta and fixtureMeta parameters of the runner.filter method.
  • Alternatively, you can store this information in the filter.testMeta and filter.fixtureMeta configuration file properties.