Testing Library

Testing Library

  • Docs
  • Recipes
  • Help
  • Blog

›DOM Testing Library

Getting Started

  • Introduction
  • Guiding Principles

Frameworks

    DOM Testing Library

    • Introduction
    • Install
    • Example
    • Setup
    • Queries
    • Firing Events
    • Async Utilities
    • Helpers
    • Configuration
    • FAQ
    • Cheatsheet

    React Testing Library

    • Introduction
    • Example
    • Setup
    • API
    • FAQ
    • Cheatsheet

    ReasonReact Testing Library

    • Introduction
    • Examples

    Native Testing Library

    • Intro
    • Example
    • Setup
    • API

    Vue Testing Library

    • Intro
    • Examples
    • Setup
    • API
  • Cypress Testing Library
  • Svelte Testing Library
  • Angular Testing Library
  • Puppeteer Testing Library
  • Testcafe Testing Library

Ecosystem

  • user-event
  • jest-dom
  • bs-jest-dom
  • jest-native
  • react-select-event
Edit

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.


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

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

configure({testIdAttribute: 'my-data-test-id'})`
The configuration object is not currently exposed to in Cypress Testing Library
Last updated on 6/1/2019
← HelpersFAQ →
  • Configuration
Testing Library
Docs
Getting StartedExamplesAPIHelp
Community
BlogStack OverflowReactiflux on DiscordSpectrum
More
StarGitHubEdit Docs on GitHub
Copyright © 2018-2019 Kent C. Dodds and contributors