-
Notifications
You must be signed in to change notification settings - Fork 404
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: Add toHaveRole matcher #572
feat: Add toHaveRole matcher #572
Conversation
I wouldn't worry about this part too much. dom-accessibility-api is the natural fit but we don't want to use aria-query in there so it's not just about copying over impl but getting rid of aria-query entirely. |
Did you file a docs PR yet? |
I made the changes to README.md in this PR. Is there some other place to change for the docs, or should I split the docs and feature into two PRs? |
@fpapado thanks a lot for taking care of this. Very thorough PR, BTW. About this:
I had not taken a look at both implementations closely enough before, but I did now. I must say that I prefer the one in dom-accessibility-api for two reasons:
However, I do sympathize with the idea of the shared implementation. I wonder why |
Thank you 😌
My gut feeling is that For invalid So I can see some value in not being strict about them, but I agree that matchers can make different decisions than the browser 😅 |
Historicaly reasons. A rewrite would not use aria-query. Ideally we'd move everything into dom-accessibility-api (the interface not the implementation) and use that everywhere. |
🎉 This PR is included in version 6.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@all-contributors please add @fpapado for code, docs, test |
I've put up a pull request to add @fpapado! 🎉 |
##### [`v6.5.0](https://github.com/testing-library/jest-dom/releases/tag/v6.5.0) ##### Features - **toHaveValue:** Asserting aria-valuenow ([#479](testing-library/jest-dom#479)) ([acbf416](testing-library/jest-dom@acbf416)) ##### [`v6.4.8](https://github.com/testing-library/jest-dom/releases/tag/v6.4.8) ##### Bug Fixes - Drop peerDependencies from package.json ([#610](testing-library/jest-dom#610)) ([faf534b](testing-library/jest-dom@faf534b)) ##### [`v6.4.7](https://github.com/testing-library/jest-dom/releases/tag/v6.4.7) ##### Bug Fixes - Type definition of `toHaveClass` ([#611](testing-library/jest-dom#611)) ([5cc6298](testing-library/jest-dom@5cc6298)) ##### [`v6.4.6](https://github.com/testing-library/jest-dom/releases/tag/v6.4.6) ##### Bug Fixes - Support [@starting-style](https://github.com/starting-style) ([#602](testing-library/jest-dom#602)) ([fd9ee68](testing-library/jest-dom@fd9ee68)) ##### [`v6.4.5](https://github.com/testing-library/jest-dom/releases/tag/v6.4.5) ##### Bug Fixes - add js suffix to isEqualWith import ([#599](testing-library/jest-dom#599)) ([e8c8b13](testing-library/jest-dom@e8c8b13)) ##### [`v6.4.4](https://github.com/testing-library/jest-dom/releases/tag/v6.4.4) ##### Bug Fixes - **infra:** codecoverage token addition ([#600](testing-library/jest-dom#600)) ([f03a582](testing-library/jest-dom@f03a582)) ##### [`v6.4.3](https://github.com/testing-library/jest-dom/releases/tag/v6.4.3) ##### Bug Fixes - Updates role support for aria-required attribute in `toBeRequired` ([#590](testing-library/jest-dom#590)) ([20aca33](testing-library/jest-dom@20aca33)) ##### [`v6.4.2](https://github.com/testing-library/jest-dom/releases/tag/v6.4.2) ##### Bug Fixes - Remove errant export of GetByRoleMatcher, fixing type checking in some TS configurations ([#575](testing-library/jest-dom#575)) ([a93c0c4](testing-library/jest-dom@a93c0c4)) ##### [`v6.4.1](https://github.com/testing-library/jest-dom/releases/tag/v6.4.1) ##### Bug Fixes - Export type `TestingLibraryMatchers` from "./matchers" ([#576](testing-library/jest-dom#576)) ([dd1c4dd](testing-library/jest-dom@dd1c4dd)) ##### [`v6.4.0](https://github.com/testing-library/jest-dom/releases/tag/v6.4.0) ##### Features - Add toHaveRole matcher ([#572](testing-library/jest-dom#572)) ([f7dc673](testing-library/jest-dom@f7dc673)) ##### [`v6.3.0](https://github.com/testing-library/jest-dom/releases/tag/v6.3.0) ##### Features - Support for regular expressions in toHaveClass ([#563](testing-library/jest-dom#563)) ([9787ed5](testing-library/jest-dom@9787ed5)) ##### [`v6.2.1](https://github.com/testing-library/jest-dom/releases/tag/v6.2.1) ##### Bug Fixes - Standalone types for "./matchers" export and add Bun support ([#566](testing-library/jest-dom#566)) ([5675b86](testing-library/jest-dom@5675b86)) ##### [`v6.2.0](https://github.com/testing-library/jest-dom/releases/tag/v6.2.0) ##### Features - toHaveAccessibleDescription supports aria-description ([#565](testing-library/jest-dom#565)) ([1fb156c](testing-library/jest-dom@1fb156c)) ##### [`v6.1.6](https://github.com/testing-library/jest-dom/releases/tag/v6.1.6) ##### Bug Fixes - Upgrade [@adobe/css-tools](https://github.com/adobe/css-tools) to v4.3.2 ([#553](testing-library/jest-dom#553)) ([b64b953](testing-library/jest-dom@b64b953)) ##### [`v6.1.5](https://github.com/testing-library/jest-dom/releases/tag/v6.1.5) ##### Bug Fixes - support uppercase custom props in toHaveStyle ([#552](testing-library/jest-dom#552)) ([b7b7c6a](testing-library/jest-dom@b7b7c6a)) ##### [`v6.1.4](https://github.com/testing-library/jest-dom/releases/tag/v6.1.4) ##### Bug Fixes - upgrade `@adobe/css-tools` to `4.3.1` to address vulnerability ([#532](testing-library/jest-dom#532)) ([44f1eab](testing-library/jest-dom@44f1eab)) ##### [`v6.1.3](https://github.com/testing-library/jest-dom/releases/tag/v6.1.3) ##### Bug Fixes - proper [@jest/globals](https://github.com/jest/globals) import ([#530](testing-library/jest-dom#530)) ([5b492ac](testing-library/jest-dom@5b492ac)) ##### [`v6.1.2](https://github.com/testing-library/jest-dom/releases/tag/v6.1.2) ##### Bug Fixes - bump [@adobe/css-tools](https://github.com/adobe/css-tools) for ESM support ([#525](testing-library/jest-dom#525)) ([b959a68](testing-library/jest-dom@b959a68)) ##### [`v6.1.1](https://github.com/testing-library/jest-dom/releases/tag/v6.1.1) ##### Bug Fixes - **package.json:** update main and module file paths ([#523](testing-library/jest-dom#523)) ([853a3e5](testing-library/jest-dom@853a3e5)) ##### [`v6.1.0](https://github.com/testing-library/jest-dom/releases/tag/v6.1.0) ##### Features - Publish ESM and CJS (testing-library/jest-dom#519) ##### [`v6.0.1](https://github.com/testing-library/jest-dom/releases/tag/v6.0.1) ##### Bug Fixes - matchers type is making the global expect unsafe ([#513](testing-library/jest-dom#513)) ([bdb34f1](testing-library/jest-dom@bdb34f1)) ##### [`v6.0.0](https://github.com/testing-library/jest-dom/releases/tag/v6.0.0) ##### Features - local types, supporting jest, [@jest/globals](https://github.com/jest/globals), vitest ([#511](testing-library/jest-dom#511)) ([4b764b9](testing-library/jest-dom@4b764b9)) ##### BREAKING CHANGES - Removes the extend-expect script. Users should use the default import path or one of the new test platform-specific paths to automatically extend the appropriate "expect" instance. extend-expect was not documented in the Readme, so this change should have minimal impact. Users can now use the following import paths to automatically extend "expect" for their chosen test platform: - [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) - jest ([@types/jest](https://github.com/types/jest)) - @testing-library/jest-dom/jest-globals - [@jest/globals](https://github.com/jest/globals) - @testing-library/jest-dom/vitest - vitest For example: import '@testing-library/jest-dom/jest-globals' Importing from one of the above paths will augment the appropriate matcher interface for the given test platform, assuming the import is done in a .ts file that is included in the user's tsconfig.json. It's also (still) possible to import the matchers directly without side effects: import \* as matchers from '@testing-library/jest-dom/matchers' - Update kcd-scripts - Drop node < 14
##### [`v6.5.0](https://github.com/testing-library/jest-dom/releases/tag/v6.5.0) ##### Features - **toHaveValue:** Asserting aria-valuenow ([#479](testing-library/jest-dom#479)) ([acbf416](testing-library/jest-dom@acbf416)) ##### [`v6.4.8](https://github.com/testing-library/jest-dom/releases/tag/v6.4.8) ##### Bug Fixes - Drop peerDependencies from package.json ([#610](testing-library/jest-dom#610)) ([faf534b](testing-library/jest-dom@faf534b)) ##### [`v6.4.7](https://github.com/testing-library/jest-dom/releases/tag/v6.4.7) ##### Bug Fixes - Type definition of `toHaveClass` ([#611](testing-library/jest-dom#611)) ([5cc6298](testing-library/jest-dom@5cc6298)) ##### [`v6.4.6](https://github.com/testing-library/jest-dom/releases/tag/v6.4.6) ##### Bug Fixes - Support [@starting-style](https://github.com/starting-style) ([#602](testing-library/jest-dom#602)) ([fd9ee68](testing-library/jest-dom@fd9ee68)) ##### [`v6.4.5](https://github.com/testing-library/jest-dom/releases/tag/v6.4.5) ##### Bug Fixes - add js suffix to isEqualWith import ([#599](testing-library/jest-dom#599)) ([e8c8b13](testing-library/jest-dom@e8c8b13)) ##### [`v6.4.4](https://github.com/testing-library/jest-dom/releases/tag/v6.4.4) ##### Bug Fixes - **infra:** codecoverage token addition ([#600](testing-library/jest-dom#600)) ([f03a582](testing-library/jest-dom@f03a582)) ##### [`v6.4.3](https://github.com/testing-library/jest-dom/releases/tag/v6.4.3) ##### Bug Fixes - Updates role support for aria-required attribute in `toBeRequired` ([#590](testing-library/jest-dom#590)) ([20aca33](testing-library/jest-dom@20aca33)) ##### [`v6.4.2](https://github.com/testing-library/jest-dom/releases/tag/v6.4.2) ##### Bug Fixes - Remove errant export of GetByRoleMatcher, fixing type checking in some TS configurations ([#575](testing-library/jest-dom#575)) ([a93c0c4](testing-library/jest-dom@a93c0c4)) ##### [`v6.4.1](https://github.com/testing-library/jest-dom/releases/tag/v6.4.1) ##### Bug Fixes - Export type `TestingLibraryMatchers` from "./matchers" ([#576](testing-library/jest-dom#576)) ([dd1c4dd](testing-library/jest-dom@dd1c4dd)) ##### [`v6.4.0](https://github.com/testing-library/jest-dom/releases/tag/v6.4.0) ##### Features - Add toHaveRole matcher ([#572](testing-library/jest-dom#572)) ([f7dc673](testing-library/jest-dom@f7dc673)) ##### [`v6.3.0](https://github.com/testing-library/jest-dom/releases/tag/v6.3.0) ##### Features - Support for regular expressions in toHaveClass ([#563](testing-library/jest-dom#563)) ([9787ed5](testing-library/jest-dom@9787ed5)) ##### [`v6.2.1](https://github.com/testing-library/jest-dom/releases/tag/v6.2.1) ##### Bug Fixes - Standalone types for "./matchers" export and add Bun support ([#566](testing-library/jest-dom#566)) ([5675b86](testing-library/jest-dom@5675b86)) ##### [`v6.2.0](https://github.com/testing-library/jest-dom/releases/tag/v6.2.0) ##### Features - toHaveAccessibleDescription supports aria-description ([#565](testing-library/jest-dom#565)) ([1fb156c](testing-library/jest-dom@1fb156c)) ##### [`v6.1.6](https://github.com/testing-library/jest-dom/releases/tag/v6.1.6) ##### Bug Fixes - Upgrade [@adobe/css-tools](https://github.com/adobe/css-tools) to v4.3.2 ([#553](testing-library/jest-dom#553)) ([b64b953](testing-library/jest-dom@b64b953)) ##### [`v6.1.5](https://github.com/testing-library/jest-dom/releases/tag/v6.1.5) ##### Bug Fixes - support uppercase custom props in toHaveStyle ([#552](testing-library/jest-dom#552)) ([b7b7c6a](testing-library/jest-dom@b7b7c6a)) ##### [`v6.1.4](https://github.com/testing-library/jest-dom/releases/tag/v6.1.4) ##### Bug Fixes - upgrade `@adobe/css-tools` to `4.3.1` to address vulnerability ([#532](testing-library/jest-dom#532)) ([44f1eab](testing-library/jest-dom@44f1eab)) ##### [`v6.1.3](https://github.com/testing-library/jest-dom/releases/tag/v6.1.3) ##### Bug Fixes - proper [@jest/globals](https://github.com/jest/globals) import ([#530](testing-library/jest-dom#530)) ([5b492ac](testing-library/jest-dom@5b492ac)) ##### [`v6.1.2](https://github.com/testing-library/jest-dom/releases/tag/v6.1.2) ##### Bug Fixes - bump [@adobe/css-tools](https://github.com/adobe/css-tools) for ESM support ([#525](testing-library/jest-dom#525)) ([b959a68](testing-library/jest-dom@b959a68)) ##### [`v6.1.1](https://github.com/testing-library/jest-dom/releases/tag/v6.1.1) ##### Bug Fixes - **package.json:** update main and module file paths ([#523](testing-library/jest-dom#523)) ([853a3e5](testing-library/jest-dom@853a3e5)) ##### [`v6.1.0](https://github.com/testing-library/jest-dom/releases/tag/v6.1.0) ##### Features - Publish ESM and CJS (testing-library/jest-dom#519) ##### [`v6.0.1](https://github.com/testing-library/jest-dom/releases/tag/v6.0.1) ##### Bug Fixes - matchers type is making the global expect unsafe ([#513](testing-library/jest-dom#513)) ([bdb34f1](testing-library/jest-dom@bdb34f1)) ##### [`v6.0.0](https://github.com/testing-library/jest-dom/releases/tag/v6.0.0) ##### Features - local types, supporting jest, [@jest/globals](https://github.com/jest/globals), vitest ([#511](testing-library/jest-dom#511)) ([4b764b9](testing-library/jest-dom@4b764b9)) ##### BREAKING CHANGES - Removes the extend-expect script. Users should use the default import path or one of the new test platform-specific paths to automatically extend the appropriate "expect" instance. extend-expect was not documented in the Readme, so this change should have minimal impact. Users can now use the following import paths to automatically extend "expect" for their chosen test platform: - [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) - jest ([@types/jest](https://github.com/types/jest)) - @testing-library/jest-dom/jest-globals - [@jest/globals](https://github.com/jest/globals) - @testing-library/jest-dom/vitest - vitest For example: import '@testing-library/jest-dom/jest-globals' Importing from one of the above paths will augment the appropriate matcher interface for the given test platform, assuming the import is done in a .ts file that is included in the user's tsconfig.json. It's also (still) possible to import the matchers directly without side effects: import \* as matchers from '@testing-library/jest-dom/matchers' - Update kcd-scripts - Drop node < 14
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) | dependencies | major | [`^5.16.4` -> `^6.0.0`](https://renovatebot.com/diffs/npm/@testing-library%2fjest-dom/5.17.0/6.6.3) | --- ### Release Notes <details> <summary>testing-library/jest-dom (@​testing-library/jest-dom)</summary> ### [`v6.6.3`](https://github.com/testing-library/jest-dom/releases/tag/v6.6.3) [Compare Source](testing-library/jest-dom@v6.6.2...v6.6.3) ##### Bug Fixes - add vitest import when extending vitest matchers ([#​646](testing-library/jest-dom#646)) ([5ba0156](testing-library/jest-dom@5ba0156)) ### [`v6.6.2`](https://github.com/testing-library/jest-dom/releases/tag/v6.6.2) [Compare Source](testing-library/jest-dom@v6.6.1...v6.6.2) ##### Bug Fixes - remove recursive type reference in vitest types ([#​636](testing-library/jest-dom#636)) ([4468378](testing-library/jest-dom@4468378)) ### [`v6.6.1`](https://github.com/testing-library/jest-dom/releases/tag/v6.6.1) [Compare Source](testing-library/jest-dom@v6.6.0...v6.6.1) ##### Bug Fixes - fix lodash import in to-have-selection.js ([#​642](testing-library/jest-dom#642)) ([ced792e](testing-library/jest-dom@ced792e)) ### [`v6.6.0`](https://github.com/testing-library/jest-dom/releases/tag/v6.6.0) [Compare Source](testing-library/jest-dom@v6.5.0...v6.6.0) ##### Features - implement toHaveSelection ([#​637](testing-library/jest-dom#637)) ([9b14804](testing-library/jest-dom@9b14804)) ### [`v6.5.0`](https://github.com/testing-library/jest-dom/releases/tag/v6.5.0) [Compare Source](testing-library/jest-dom@v6.4.8...v6.5.0) ##### Features - **toHaveValue:** Asserting aria-valuenow ([#​479](testing-library/jest-dom#479)) ([acbf416](testing-library/jest-dom@acbf416)) ### [`v6.4.8`](https://github.com/testing-library/jest-dom/releases/tag/v6.4.8) [Compare Source](testing-library/jest-dom@v6.4.7...v6.4.8) ##### Bug Fixes - Drop peerDependencies from package.json ([#​610](testing-library/jest-dom#610)) ([faf534b](testing-library/jest-dom@faf534b)) ### [`v6.4.7`](https://github.com/testing-library/jest-dom/releases/tag/v6.4.7) [Compare Source](testing-library/jest-dom@v6.4.6...v6.4.7) ##### Bug Fixes - Type definition of `toHaveClass` ([#​611](testing-library/jest-dom#611)) ([5cc6298](testing-library/jest-dom@5cc6298)) ### [`v6.4.6`](https://github.com/testing-library/jest-dom/releases/tag/v6.4.6) [Compare Source](testing-library/jest-dom@v6.4.5...v6.4.6) ##### Bug Fixes - Support [@​starting-style](https://github.com/starting-style) ([#​602](testing-library/jest-dom#602)) ([fd9ee68](testing-library/jest-dom@fd9ee68)) ### [`v6.4.5`](https://github.com/testing-library/jest-dom/releases/tag/v6.4.5) [Compare Source](testing-library/jest-dom@v6.4.4...v6.4.5) ##### Bug Fixes - add js suffix to isEqualWith import ([#​599](testing-library/jest-dom#599)) ([e8c8b13](testing-library/jest-dom@e8c8b13)) ### [`v6.4.4`](https://github.com/testing-library/jest-dom/releases/tag/v6.4.4) [Compare Source](testing-library/jest-dom@v6.4.3...v6.4.4) ##### Bug Fixes - **infra:** codecoverage token addition ([#​600](testing-library/jest-dom#600)) ([f03a582](testing-library/jest-dom@f03a582)) ### [`v6.4.3`](https://github.com/testing-library/jest-dom/releases/tag/v6.4.3) [Compare Source](testing-library/jest-dom@v6.4.2...v6.4.3) ##### Bug Fixes - Updates role support for aria-required attribute in `toBeRequired` ([#​590](testing-library/jest-dom#590)) ([20aca33](testing-library/jest-dom@20aca33)) ### [`v6.4.2`](https://github.com/testing-library/jest-dom/releases/tag/v6.4.2) [Compare Source](testing-library/jest-dom@v6.4.1...v6.4.2) ##### Bug Fixes - Remove errant export of GetByRoleMatcher, fixing type checking in some TS configurations ([#​575](testing-library/jest-dom#575)) ([a93c0c4](testing-library/jest-dom@a93c0c4)) ### [`v6.4.1`](https://github.com/testing-library/jest-dom/releases/tag/v6.4.1) [Compare Source](testing-library/jest-dom@v6.4.0...v6.4.1) ##### Bug Fixes - Export type `TestingLibraryMatchers` from "./matchers" ([#​576](testing-library/jest-dom#576)) ([dd1c4dd](testing-library/jest-dom@dd1c4dd)) ### [`v6.4.0`](https://github.com/testing-library/jest-dom/releases/tag/v6.4.0) [Compare Source](testing-library/jest-dom@v6.3.0...v6.4.0) ##### Features - Add toHaveRole matcher ([#​572](testing-library/jest-dom#572)) ([f7dc673](testing-library/jest-dom@f7dc673)) ### [`v6.3.0`](https://github.com/testing-library/jest-dom/releases/tag/v6.3.0) [Compare Source](testing-library/jest-dom@v6.2.1...v6.3.0) ##### Features - Support for regular expressions in toHaveClass ([#​563](testing-library/jest-dom#563)) ([9787ed5](testing-library/jest-dom@9787ed5)) ### [`v6.2.1`](https://github.com/testing-library/jest-dom/releases/tag/v6.2.1) [Compare Source](testing-library/jest-dom@v6.2.0...v6.2.1) ##### Bug Fixes - Standalone types for "./matchers" export and add Bun support ([#​566](testing-library/jest-dom#566)) ([5675b86](testing-library/jest-dom@5675b86)) ### [`v6.2.0`](https://github.com/testing-library/jest-dom/releases/tag/v6.2.0) [Compare Source](testing-library/jest-dom@v6.1.6...v6.2.0) ##### Features - toHaveAccessibleDescription supports aria-description ([#​565](testing-library/jest-dom#565)) ([1fb156c](testing-library/jest-dom@1fb156c)) ### [`v6.1.6`](https://github.com/testing-library/jest-dom/releases/tag/v6.1.6) [Compare Source](testing-library/jest-dom@v6.1.5...v6.1.6) ##### Bug Fixes - Upgrade [@​adobe/css-tools](https://github.com/adobe/css-tools) to v4.3.2 ([#​553](testing-library/jest-dom#553)) ([b64b953](testing-library/jest-dom@b64b953)) ### [`v6.1.5`](https://github.com/testing-library/jest-dom/releases/tag/v6.1.5) [Compare Source](testing-library/jest-dom@v6.1.4...v6.1.5) ##### Bug Fixes - support uppercase custom props in toHaveStyle ([#​552](testing-library/jest-dom#552)) ([b7b7c6a](testing-library/jest-dom@b7b7c6a)) ### [`v6.1.4`](https://github.com/testing-library/jest-dom/releases/tag/v6.1.4) [Compare Source](testing-library/jest-dom@v6.1.3...v6.1.4) ##### Bug Fixes - upgrade `@adobe/css-tools` to `4.3.1` to address vulnerability ([#​532](testing-library/jest-dom#532)) ([44f1eab](testing-library/jest-dom@44f1eab)) ### [`v6.1.3`](https://github.com/testing-library/jest-dom/releases/tag/v6.1.3) [Compare Source](testing-library/jest-dom@v6.1.2...v6.1.3) ##### Bug Fixes - proper [@​jest/globals](https://github.com/jest/globals) import ([#​530](testing-library/jest-dom#530)) ([5b492ac](testing-library/jest-dom@5b492ac)) ### [`v6.1.2`](https://github.com/testing-library/jest-dom/releases/tag/v6.1.2) [Compare Source](testing-library/jest-dom@v6.1.1...v6.1.2) ##### Bug Fixes - bump [@​adobe/css-tools](https://github.com/adobe/css-tools) for ESM support ([#​525](testing-library/jest-dom#525)) ([b959a68](testing-library/jest-dom@b959a68)) ### [`v6.1.1`](https://github.com/testing-library/jest-dom/releases/tag/v6.1.1) [Compare Source](testing-library/jest-dom@v6.1.0...v6.1.1) ##### Bug Fixes - **package.json:** update main and module file paths ([#​523](testing-library/jest-dom#523)) ([853a3e5](testing-library/jest-dom@853a3e5)) ### [`v6.1.0`](https://github.com/testing-library/jest-dom/releases/tag/v6.1.0) [Compare Source](testing-library/jest-dom@v6.0.1...v6.1.0) ##### Features - Publish ESM and CJS (testing-library/jest-dom#519) ### [`v6.0.1`](https://github.com/testing-library/jest-dom/releases/tag/v6.0.1) [Compare Source](testing-library/jest-dom@v6.0.0...v6.0.1) ##### Bug Fixes - matchers type is making the global expect unsafe ([#​513](testing-library/jest-dom#513)) ([bdb34f1](testing-library/jest-dom@bdb34f1)) ### [`v6.0.0`](https://github.com/testing-library/jest-dom/releases/tag/v6.0.0) [Compare Source](testing-library/jest-dom@v5.17.0...v6.0.0) ##### Features - local types, supporting jest, [@​jest/globals](https://github.com/jest/globals), vitest ([#​511](testing-library/jest-dom#511)) ([4b764b9](testing-library/jest-dom@4b764b9)) ##### BREAKING CHANGES - Removes the extend-expect script. Users should use the default import path or one of the new test platform-specific paths to automatically extend the appropriate "expect" instance. extend-expect was not documented in the Readme, so this change should have minimal impact. Users can now use the following import paths to automatically extend "expect" for their chosen test platform: - [@​testing-library/jest-dom](https://github.com/testing-library/jest-dom) - jest ([@​types/jest](https://github.com/types/jest)) - @​testing-library/jest-dom/jest-globals - [@​jest/globals](https://github.com/jest/globals) - @​testing-library/jest-dom/vitest - vitest For example: import '@​testing-library/jest-dom/jest-globals' Importing from one of the above paths will augment the appropriate matcher interface for the given test platform, assuming the import is done in a .ts file that is included in the user's tsconfig.json. It's also (still) possible to import the matchers directly without side effects: import \* as matchers from '@​testing-library/jest-dom/matchers' - Update kcd-scripts - Drop node < 14 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS44LjAiLCJ1cGRhdGVkSW5WZXIiOiIzOS44LjAiLCJ0YXJnZXRCcmFuY2giOiJtYXN0ZXIiLCJsYWJlbHMiOltdfQ==--> Reviewed-on: https://gitea.bruyant.xyz/alexandre/PaletteSwitcher/pulls/58 Co-authored-by: Renovate <[email protected]> Co-committed-by: Renovate <[email protected]>
What:
This PR adds the
toHaveRole
matcher described in #143.Why:
Sometimes, it is desirable to make assertions about the accessible role of an element. While the prioritites in testing-library encourage querying an element by its role, there are times when you already have access to an element, and want to run assertions, without changing the query itself. For example, some codebases prioritise test ids over role queries. This enables more robust accessibility checks for these scenarios :)
How:
In large part, I am porting over dom-testing-library's role helpers to this one.
Under the hood, the role helpers use aria-query which gives programmatic (and auto-updating) access to the ARIA specification and its HTML mappings.
The helpers then compile the different conditions (attributes, DOM tree relationships) into a CSS selector, and provide a function to match an element via the
HTMLElement
matches()
method.Checklist:
Questions for the maintainers
I have two main questions, that I would want the maintainers to clarify:
aria-query
mappings)dom-testing-library
, I have a gut feeling that we could move these helpers to a shared package. I noticed that @eps1lon's dom-accessibility-api also has agetRole function
, albeit with a different implementation. I have not looked enough into it, to evaluate which one is more fit for this use-case. Do you have any preferences?Question 1. is more imminent for this PR, I suppose 😁 Question 2. can be an implementation detail, that we can tackle in a follow-up. I leave it up to you.
Please let me know if there is any other information that I can provide!