feat(configureTestIdAttribute): add ability to override data-testid [specific config] #163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 needingto 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 toqueries.js
, but we assume elsewhere that all exports fromqueries.js
are queries, and I didn't want to alter that. So I added a simpleconfig.js
module to store the actual configuration, andqueries.js
references that andindex.js
exposes the tiny configuration API.Checklist: