testing-library / dom-testing-library

🐙 Simple and complete DOM testing utilities that encourage good testing practices.
https://testing-library.com/dom
MIT License
3.26k stars 466 forks source link

fix(ByRole): Constrain API #1211

Closed eps1lon closed 1 year ago

eps1lon commented 1 year ago

BREAKING CHANGE: Only allow string as a role. Drop support for exact, trim, collapseWhitespace, and normalizer options.

What:

Closes https://github.com/testing-library/dom-testing-library/issues/1202

Why:

Options are not needed as far as I can tell. From the tests we have, it seems to me this encourages rather bad queries. Will ship this soon-ish (since it's just an alpha) to test.

How:

Checklist:

codesandbox-ci[bot] commented 1 year ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit deaeef27912f814c106a966ad492c4a3a9a7e3c6:

Sandbox Source
react-testing-library-examples Configuration
codecov[bot] commented 1 year ago

Codecov Report

Merging #1211 (deaeef2) into alpha (42809fe) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##             alpha     #1211   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           24        24           
  Lines         1000       992    -8     
  Branches       328       322    -6     
=========================================
- Hits          1000       992    -8     
Flag Coverage Δ
node-14 100.00% <100.00%> (ø)
node-16 100.00% <100.00%> (ø)
node-18 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/queries/role.ts 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

remidej commented 1 year ago

Hello! I know byRole often has perf issues when used on large dom nodes. Do you expect this PR to improve the performance?