Commit Graph

66 Commits

Author SHA1 Message Date
Maciej Jastrzebski 16b9e493f7 refactor: pass through Test Renderer options (#1594) 2024-04-26 23:14:43 +02:00
Maciej Jastrzebski 21254b059a chore: reformat source using prettier (#1550)
* chore: reformat source using prettier
* chore: fix lint
2024-01-03 22:31:12 +01:00
Stephen Hanson f7c8400246 feat: Render element tree in query error messages (#1378)
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2023-04-27 11:05:10 +02:00
Maciej Jastrzebski 4256d0c83c v12 release (#1314)
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
Co-authored-by: Pierre Zimmermann <64224599+pierrezimmermannbam@users.noreply.github.com>
2023-03-15 09:41:38 +01:00
Maciej Jastrzebski 47b125c195 refactor(breaking): rename container to UNSAFE_root; introduce root host element (#1298) 2023-02-14 00:32:51 +01:00
Pierre Zimmermann d261f6100e feat(breaking): Return host component for all queries (#1234)
* BREAKING CHANGE : make placeholdertext queries return host elements

* BREAKING CHANGE : make displayValue queries return host elements

* BREAKING CHANGE: make text queries return host elements

* refactor: reset config to default before each test

* feat: use component names from config and add api to configure them

* feat: remove legacy option from queries

* refactor: reorganize legacy and breaking tests for queries

* feat: change error messages for mismatching host component names

* fix: do not update screen when running auto detection

* fix: typo in comment

* refactor: use an object for matchTextContent params

* tests: rewrite some tests to match repo patterns

* fix: use legacy queries by default to prevent breaking changes

* fix: remove wrong uppercase in flow typings

* docs: remove section on useLegacy queries as it wont be a public api

* docs: small improvements based on review

* fix: remove typo in error message

* refactor: rename getReactNativeHostComponentNames to detectHostComponentNames

* refactor: use useBreakingChange from internal config instead of useLegacyQueries

* fix: use fake timers in test so it doesnt take too much time

* refactor: replace type assertions by real type checking

* fix: revert change due to rebase

* fix: improvements after review

* refactor: define type to match inside matchTextContent function

* refactor: rename function to get error message

* feat: display error when auto detect of host component names throw

* fix: remove unused ts-expect-error after ts version bump

* refactor: run auto detection on render if it hasnt been run yet

* refactor: reuse type imports that had been converted to regular ones

* refactor: add comments to distinguish breaking and legacy

* refactor: move config logic into detectComponentHostNames function

* refactor: rename function to detectComponentHostNamesIfNeeded

* tests: add test on detectHostComponentNamesIfNeeded

* fix: use host component name from config for textinput in fireEvent

* refactor: run autodetection in text, displayvalue and placeholder queries rather than in render

* refactor: remove useless async declaration

* refactor: improvements for readability from review

* Update src/__tests__/host-component-names.test.tsx

* refactor: declare variable for host component names in detection function

* refactor: rename detectHostComponentNamesIfNeeded to getHostComponentNames

* feat: use getHostComponentNames in fireEvent for textinput host name

* refactor: revert refactor on matchTextContent

* refactor: add comment to indicate impossible path

* chore: simplify jest-setup files

* refactor: code review changes

Co-authored-by: pierrezimmermann <pierrez@nam.tech>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2023-01-15 23:13:27 +01:00
Maciej Jastrzebski 527ea62623 feat: *ByRole a11y value option (#1210) 2022-11-15 16:53:10 +01:00
MattAgn c9c0493903 Add alias to hidden in query options (#1220)
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2022-11-15 11:18:03 +01:00
Maciej Jastrzebski 92cb031ad6 feat: alias isInaccessible as isHiddenFromAccessibility (#1211) 2022-11-08 11:17:21 +01:00
MattAgn 860356be06 feat: option for queries to respect accessibility (#1064)
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2022-11-04 22:44:50 +01:00
Pierre Zimmermann a78f3e4134 feat: debug options (#1160)
Co-authored-by: pierrezimmermann <pierrez@nam.tech>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2022-11-03 12:52:51 +01:00
Shaswat Prabhat 52222b42b4 Add queryOptions to labelText and hintText (#1193)
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2022-10-31 12:10:45 +01:00
Augustin Le Fèvre 7ae763ff65 Query by role and accessibilityState and improve ByRole query errors (#1161) 2022-10-20 11:52:10 +02:00
Pierre Zimmermann 17e2021030 fix: update render flow type with new option unstable_validateStringsRenderedWithinText (#1179)
Co-authored-by: pierrezimmermann <pierrez@nam.tech>
2022-10-17 23:16:29 +02:00
Maciej Jastrzebski 932c547b3b feature: configure API from DTL (#1141) 2022-09-27 16:18:55 +02:00
Augustin Le Fèvre c9ab3cf549 Add support for ByRole with name (#1127)
Co-authored-by: Kiran Jd <kiranjd8@gmail.com>
2022-09-22 14:34:51 +02:00
Maciej Jastrzebski 2c096fff99 feature: export options types and renderHook result type (#1091) 2022-09-06 12:54:39 +02:00
Maciej Jastrzebski 9f3b31dd9d refactor: remove deprecated byA11yStates queries (#1015) 2022-07-20 12:33:19 +02:00
Maciej Jastrzebski 5d681790bf feat: add screen API (#994)
* feature: screen

* feature: update docs

* refactor: add flow type

* docs: more

* docs: final tweaks

* test rerender

* code review changes

* alias RenderResult to RenderAPI

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2022-06-24 13:17:06 +02:00
Maciej Jastrzebski 64ff2d27c2 refactor: re-organise regular (non A11y) queries by predicate (#965)
* refactor: move queries files to queries folder

* refactor: fix import order

* refactor: extract bindByTextQueries

* refactor: extract bindByTestId, bindByDisplayValue

* refactor: extract bindByPlaceholderText

* refactor: remove findByAPI

* refactor: re-organied flow types

* refactor: migrate getByAPI & queryByAPI

* refactor: simplify query file names

* refactor: reduce external visibility

* refactor: reduce unnecessary exports

* refactor: self code review

* refactor: self code review

* refactor: move query tests to `src/queries/__tests__`

* refactor: remove removed functions errors
2022-05-04 12:08:03 +02:00
Pierre Zimmermann 564e99056a feat: add renderHook function (#923)
* feat: add renderHook function

* docs: add documentation on renderhook

* chore(renderHook): add flow typing

* docs: improve readability and consistency

Co-authored-by: pierrezimmermann <pierrez@nam.tech>
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2022-04-26 14:53:59 +02:00
Augustin Le Fèvre 1360b73295 feat(breaking): migrate Flow to TS; remove some deprecated functions and aliases (#881)
* Port types to TS

* Fix CI commands

* Fix typo in yml file

* Address PR comments

* Remove aliased accessibility queries

* Add flow types

* Update build to support TS

* Clean up removed aliased queries

* Move @babel/plugin-transform-flow-strip-types to test config

* Address PR comments

* Delete flow tests

* Retrigger pipeline

* Update src/helpers/timers.ts

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2022-03-25 16:54:30 +01:00
Jared Beach 6667cc2e20 feat: adds onTimeout option to waitFor (#885) 2022-01-10 13:09:24 +01:00
Augustin Le Fèvre 31ef0b92ed feat(breaking): add text match options a.k.a string precision API (#554)
* Add TextMatch options to getByAPI

* Add TextMatch options to queryByAPI

* Add TextMatch options to findByAPI

* Add tests covering new TextMatch options

* Add documentation and examples for TextMatch options

* Implement text match normalization customization

* Implement tests for normalization options

* Add text normalization docs

* Refactor typings

* Add export for getDefaultNormalizer function

* Remove undocumented config for normalizer function

* Update website/docs/Queries.md

Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>

* BREAKING: make findBy* queries arguments order compatible with RTL

* Fix tests for findBy queries after changing their API

* Fix matching nested Text components with queryOptions exact set to true

* Remove recursion matching for *byText APIs

* Reuse getAllByText in getByText

* Add Textmatch options to *byTestId

* fix: types for getDefaultNormalizer

* refactor: remove makeNormalizer and use getDefaultNormalizer() instead

* refactor: change params position and description for matches

* refactor: move & remove duplicated tests after merge

* Make waitForOptions param change non breaking change

* chore: cleanup and type fixups

* tests: update snapshots

* chore: use default arg value for normalizer

* Restore mock after use

* fix: wrong snapshot update with outdated deps

Co-authored-by: Rafał Zakrzewski <zakrzewski.rafal@gmail.com>
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
Co-authored-by: Damian Sznajder <damsznajder@gmail.com>
2021-11-23 16:30:25 +01:00
Augustin Le Fèvre 3735b0e41f Forward extra data to press event (#828) 2021-10-15 21:02:34 +02:00
Ilya.Stepanov 2ab2645e1d Update index.d.ts (#812)
toJSON function can return a list of ReactTestRendererJSON
2021-09-13 12:55:48 +02:00
Benjamin Reid e9f6d694f4 Debug implicit any error (#697)
* any return time for Debug (implicit any errors)

* Update typings/index.d.ts

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2021-03-03 18:18:48 +01:00
Michał Pierzchała 2b36511090 fix: correct TS typings for debug.shallow (#584) 2020-11-02 18:46:56 +01:00
Jason Cheatham b74b15faf2 fix: add container to TypeScript types (#582)
Update the TS types for the new `container` property that was added to
the output of `render` in #567.
2020-10-28 15:33:23 +01:00
Alvaro Catalina d55ea0b0b4 feat: RegExp support for *ByTestId queries (#535)
* getAllByTestId supports a regex matcher

* update typings

* docs: update

* refactor types

* refactor. remove unnecessary try/catch

* refactor test assertions
2020-09-07 22:39:16 +02:00
Alireza Ghamkhar 6bf86f915f Fix the type bug for queryAllByTestId (#498) 2020-08-11 17:41:02 +02:00
Maciej Jastrzebski 3f88cacbc6 feat: add getQueriesForElement alias to within (#461)
* feat: getQueriesForElement alias implementation & test

* feat: added typescript types and tests

* feat: updated docs
2020-07-30 16:13:15 +02:00
Michał Pierzchała 6d63a4f29e feat(breaking): rename ByPlaceholder to ByPlaceholderText (#455) 2020-07-30 16:13:15 +02:00
Ryan Wessel 61359c70e6 feat: introduce ByLabelText, ByRole and ByHintText a11y aliases (#445)
* feat: Add alias accessibilityLabel queries to assist in migrating from @testing-library/react-native

* feat: Add alias accessibilityHint queries to assist in migrating from @testing-library/react-native

* feat: Add alias accessibilityRole queries to assist in migrating from @testing-library/react-native

* feat: Add to A11yAPI types to include the newly-aliased queries for label, hint, and role

* test: Add tests for newly-aliased label, hint, and role a11y queries

* test: Add newly-alised a11y queries to the index typings test file

* docs: Add query aliases for testing library migrators to Queries documentation

* test: Consolidate aliased query tests into shared tests. FIXME's where there are errors

* test: Update a11yAPI tests to assert referential equality for query aliases

* refactor: apply Prettier formatting to a11yAPI test file

* fix: address typos in CONTRIBUTING.md

* test: Separate referential quality assertion tests for query aliases into their own tests

Co-authored-by: Ryan Wessel <rwessel@dataminr.com>
2020-07-21 15:46:06 +02:00
Kadi Kraman 5ed2b8bcd5 fix: add a @ts-ignore for AccessibilityStates to support types for RN0.62+ (#440) 2020-07-16 15:05:53 +02:00
Maciej Jastrzebski 300d16b822 feature: wait for element to be removed (#376)
* feature: basic implementation

* feature: basic implementation

* feature: added typescript types

* feature: check if element exists initially

* resolve promise with initial elements

* docs: README & API

* use ErrorWithStack helper

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2020-06-10 08:17:01 +02:00
Maciej Jastrzebski 9e50bff6ab chore(breaking): deprecate flushMicrotasksQueue (#340)
* Deprecated flushMicrotasksQueue

* Update website/docs/Migration20.md

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>

* Renamed flushMicrotasksQueueInternal to flushMicroTasks

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2020-05-28 15:06:04 +02:00
Maciej Jastrzebski 40ed26812d chore: reorganize TS test file (#337) 2020-05-28 15:06:04 +02:00
Maciej Jastrzebski 9fc83fec60 Feat(breaking): remove deprecated functions (#334)
* WIP

* More changes

* WIP

* Added throwRemovedFunctionError docsRef

* Fixed tests

* Typescript types cleanup

* Cleanup

* Moving some changes from `prepare-2` branch

* Moving some changes from `prepare-2` branch

* Update src/waitFor.js

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>

* Update website/docs/Migration20.md

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>

* Code review changes

* More code review changes

* Code review changes

* More code review changes

* Added @deprecated messages for TS type defs

* Spelling mistake

* Reformatted index.d.ts

* Removed remaining refs to warnFn

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2020-05-28 15:06:04 +02:00
Maciej Jastrzebski 5e798bc2e3 Feat(breaking): unify wait for element signature with testing library (#327)
* Change argument to options object

* Renamed `waitForElement` to `waitFor`

* Migration guide entry

* Fixed typescript check

* Update src/helpers/a11yAPI.js

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>

* (Nearly) Empty migration doc for ver. 2.0 (#326)

* Added migration docs section

* Added to docosaurus side bar

* Updated README

* Increased async test timeout

* Update website/docs/Migration20.md

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>

* feat(breaking): remove legacy `debug` export (#328)

* Removed global `debug` functions

* Removed global `debug` from docs

* Cleanup

* Added migration section

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2020-05-28 15:06:04 +02:00
Maciej Jastrzebski 043f51d36c feat(breaking): remove legacy debug export (#328)
* Removed global `debug` functions

* Removed global `debug` from docs

* Cleanup

* Added migration section

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2020-05-28 15:06:04 +02:00
Maciej Jastrzebski ab34712133 feat: add findBy* queries (#304)
* Basic async findBy queries

* Refactored findBy queries to be built with makeFindQuery

* findBy queries for A11y selectors

* Custom findByTestId implementation that avoids current getByTestId issues

* Fixed prettier issue

* Updates Queries.md with findBy queries

* Trying to fix test timeout error appearing only on CI

* Code review changes

* Added typescript types & tests

* prettier did reformat some code arround

* Removed export of GetByAPI, QueryByAPI and FindByAPI interfaces in TS

* Reversed prettier run on typings

* Added overlapping pieces with `within` operator

* Small cleanup

* Update website/docs/Queries.md

* Moved async/await tests to the end of test methods

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2020-05-15 09:52:33 +02:00
Maciej Jastrzebski 1809825313 feat: add within operator for returned instance-bound queries (#306)
* Basic within implementation and tests

* Added typescript types & tests

* Removed duplicated import in index.d.ts

* Reversed prettier run on typings

* Fixed package level exports for `within` operator

* Replaced getByTestId queries with getByA11yHint queries in unit tests for `within`

* Added `within` section to API.md

* Updated README.md regarding `within` operator

* Update website/docs/API.md

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2020-05-14 12:51:19 +02:00
Kacper Wiszczuk 9edcd16c72 feat: byA11yValue matcher (#262) 2020-03-18 10:42:20 +01:00
Kacper Wiszczuk 960080d210 imp: Re-alias deprecated matchers and warn (#261)
* imp: Re-alias deprecated matchers

* Prepare for byName deletion
2020-03-18 10:30:41 +01:00
Kacper Wiszczuk 62cda2205b feat: byA11yState matcher (#260)
* feat: byA11yState matcher

* Kick CI

* Update src/helpers/a11yAPI.js

Co-Authored-By: Michał Pierzchała <thymikee@gmail.com>

* Correct types

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2020-03-18 10:06:31 +01:00
Alec Larson 4c77f4a7dc feat: add "cleanup" function (#237)
* feat: add "cleanup" function

* docs: add "cleanup" section

* test: "cleanup" function

* don't expose cleanup queue


Co-authored-by: Alec Larson <alec.stanford.larson@gmail.com>
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2019-12-09 11:41:48 +01:00
Kacper Wiszczuk d216b108b9 fix: correct Flow and TS typings for a11y queries (#205) 2019-07-17 12:10:22 +02:00
Kacper Wiszczuk 31f476bb7c feat: support multiple params in event handlers (#203) 2019-07-16 16:19:59 +02:00
Scotty Waggoner fead652013 feat: add getAllByTestId and queryAllByTestId queries (#198)
* feat: add getAllByTestId and queryAllByTestId queries

* Add test for getAllByTestId and queryAllByTestId

- Filter out intermediate components in getAllByTestId. testIDs may be passed down to child components and appearing multiple times in the render tree. Some React Native components render multiple anyways. <Text> is an example.

* Update TypeScript typings

* Fix flow types

* Update TS typings test
2019-07-03 10:17:32 +02:00