Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(configureTestIdAttribute): add ability to override data-testid [specific config] #163

Conversation

RoystonS
Copy link
Contributor

N.B. This is one of two alternative PRs with slightly differing configuration APIs. This one contains a specific configuration API exposing one function targeted at changing the test id attribute.

What:

Introduce an API to allow data-testid to be overridden without consumers needing
to construct and maintain a set of higher level decorator functions to override the various 'xxxByTestId' functions as exposed in various places.

Why:

The existing API, where data-testid cannot be changed at the low level, requires a significant amount of effort to customise the higher-level APIs. See issue #162 for more discussion.

How:

Ultimately we needed to parameterise what was previously some hardcoded strings in queries.js. I would have preferred to keep the changes local to queries.js, but we assume elsewhere that all exports from queries.js are queries, and I didn't want to alter that. So I added a simple config.js module to store the actual configuration, and queries.js references that and index.js exposes the tiny configuration API.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table

Adds the configureTestIdAttribute function that enables the overriding of
data-testid without having to write and maintain higher-level decoration
to replace all the ByTestId queries in various places.
@kentcdodds
Copy link
Member

If we do this, we'll go with the other PR 👍

@kentcdodds kentcdodds closed this Nov 28, 2018
@RoystonS RoystonS deleted the pr/configure-testid-specific-config branch November 28, 2018 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants