Skip to content

Files

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Latest commit

2b662d1 · May 31, 2019

History

History
51 lines (34 loc) · 1.14 KB

api-configuration.md

File metadata and controls

51 lines (34 loc) · 1.14 KB
id title
api-configuration
Configuration

Configuration

The library can be configured via the configure function, which accepts:

  • a plain JS object; this will be merged into the existing configuration. e.g. configure({testIdAttribute: 'not-data-testid'})
  • a function; the function will be given the existing configuration, and should return a plain JS object which will be merged as above, e.g. configure(existingConfig => ({something: [...existingConfig.something, 'extra value for the something array']}))

Configuration options:

testIdAttribute: The attribute used by getByTestId and related queries. Defaults to data-testid. See getByTestId.

// setup-tests.js
import { configure } from '@testing-library/dom'

configure({testIdAttribute: 'my-data-test-id'})`
// setup-tests.js
import { configure } from 'react-testing-library'

configure({testIdAttribute: 'my-data-test-id'})`
The configuration object is not currently exposed to in Cypress Testing Library