165 Commits

Author SHA1 Message Date
Jarda Snajdr 6bf8d246e6 detectHostComponentNames: render test tree inside act to avoid timer leaks (#1371)
* detectHostComponentNames: render test tree inside act to avoid timer leaks

* chore: tweaks

* refactor: extract common renderWithAct function

* chore: tweaks

---------

Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2023-03-23 10:48:17 +01:00
Jarda Snajdr f79d41dc6a Flush all pending microtasks and updates before returning from waitFor (#1366)
* Flush all pending microtasks and updates before returning from waitFor

* Disable a linter error, its advice is not good

* refactor: use `flushMicroTasks` util

* refactor: add legacy fake timer test

* refactor: tweaks

---------

Co-authored-by: Maciej Jastrzębski <mdjastrzebski@gmail.com>
2023-03-23 10:04:45 +01: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 468f7f5992 fix: disable container deprecation warning (main) (#1362)
* fix: disable container deprecation warning

* chore: fix lint
2023-03-08 14:46:31 +01:00
Maciej Jastrzebski eb2e087002 fix: duplicate AccessibilityState type (cherry-pick of #1355) (#1361) 2023-03-07 08:00:41 +01:00
renovate[bot] 3c48c3e908 chore(deps): update dependency react-native to v0.71.3 (#1323)
* chore(deps): update dependency react-native to v0.71.3

* chore: remove @ts-expect-errors comments

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2023-02-16 11:50:47 +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
Maciej Jastrzebski 2b5d0d2a3d fix: get host component names on render (modified) (#1306)
Co-authored-by: pierrezimmermann <pierrez@nam.tech>
2023-02-08 15:09:20 +01:00
Maciej Jastrzebski 8bd19520bf chore: deprecate some a11y queries (#1226) 2023-01-28 22:31:56 +01:00
Maciej Jastrzebski 4decd45f5e fix: force cast await to proper type (#1293)
* fix: force cast await to proper type

* fix: ci

* refactor: remove support for mock act

* refactor: tweaks

* chore: remove unused test

* chore: fix lint

* refactor: code review changes
2023-01-26 22:28:10 +01:00
Patryk Fryda 0af721144f feat: check accessibilityLabelledBy in *ByLabelText queries (#1191)
* feat: check accessibilityLabelledBy in *ByLabelText queries

* refactor: move getNodeByText to matchTextContent helper

* test: improve getByLabelText tests

* refactor: extract matchLabelText

* refactor: tweaks

* refactor: code review changes

* refactor: code review changes

* chore: rebase on main

* chore: fix lint

* chore: fix test code in files

* chore: fix lint

* chore: fix ts error due to missing RN typing

Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2023-01-23 23:52:24 +01:00
dependabot[bot] 25613807b8 chore(deps-dev): bump react and react-native (#1278)
* chore(deps-dev): bump react and react-native

Bumps [react](https://github.com/facebook/react/tree/HEAD/packages/react) and [react-native](https://github.com/facebook/react-native). These dependencies needed to be updated together.

Updates `react` from 18.1.0 to 18.2.0
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/v18.2.0/packages/react)

Updates `react-native` from 0.70.6 to 0.71.0
- [Release notes](https://github.com/facebook/react-native/releases)
- [Changelog](https://github.com/facebook/react-native/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/react-native/compare/v0.70.6...v0.71.0)

---
updated-dependencies:
- dependency-name: react
  dependency-type: direct:development
  update-type: version-update:semver-minor
- dependency-name: react-native
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: update snapshots

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Maciej Jastrzębski <mdjastrzebski@gmail.com>
2023-01-18 13:16:08 +01:00
MattAgn 5f94d527ca byRole queries return only accessibility elements (#1244)
* refactor: group tests in accessibility

* feat: add isAccessibilityElement helper

* chore: fix typo

* feat: handle accessible in byrole

* feat: only check accessibility when useBreakingChanges true

* test: group a11y tests together

* test: add implicit accessible test

* test: review byrole test titles

* test: add test case for byRole

* refactor: code review changes

* fix: code cov warnings

Co-authored-by: Maciej Jastrzębski <mdjastrzebski@gmail.com>
2023-01-17 23:49:29 +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 4efd7e291b feat: config option to allow breaking changes (#1241) 2022-12-02 10:14:20 +01:00
Maciej Jastrzebski 647ae262cd fix: improve text matching (#1222) 2022-11-17 13:08:38 +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
Pierre Zimmermann 380ff320c0 fix: do not use a real timeout in waitfor when using fake timers (#1177)
* fix: do not use a real timeout in waitfor when using fake timers

* refactor: rewrite test so that it is more explicit

* refactor: make test faster by decreasing both interval and timeout

* refactor: expect waitFor to throw rather than wrapping in try catch

* test: fix typo in test comment

* tests: increase a bit interval so test is more robust and make it more explicit

* tests: some improvements from review

* Update expect comment following review suggestion

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

Co-authored-by: pierrezimmermann <pierrez@nam.tech>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2022-10-31 11:22:52 +01:00
Maciej Jastrzebski bd5ddd7bc4 fix: *ByA11yState default value false value for busy, disabled & selected state (#1166) 2022-10-21 11:06:57 +02: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
Nir Yosef 8356d2cff9 Ignore fake timers (#1169) 2022-10-18 13:41:28 +02:00
Augustin Le Fèvre 2520735e09 fix: *ByRole queries to match their own text text content (#1139) 2022-10-04 10:06:09 +02:00
Maciej Jastrzebski ce54ab30f7 chore: ReactNative API assumptions early warning tests (#1143) 2022-09-28 13:51:34 +02:00
Maciej Jastrzebski 932c547b3b feature: configure API from DTL (#1141) 2022-09-27 16:18:55 +02:00
Maciej Jastrzebski fa21fc52d4 feat: isInaccessible API form RTL/DTL (#1128) 2022-09-23 19:33:48 +02:00
Augustin Le Fèvre 807898e792 Switch to IS_REACT_ACT_ENVIRONMENT instead of act when needed when using react 18 (#1131) 2022-09-22 23:44:09 +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
Pierre Zimmermann f80745f37d Feat : emulate string outside text error (#1070) 2022-09-19 15:05:58 +02:00
Augustin Le Fèvre 10e69c5f67 Add support for testing with react@17 (#1115)
* Add support for testing with react@17

* Test with react@17 through a script updating dependencies

* Use test:ci command also for react@17

* Minor adjustements to script

* Update scripts/test_react_17

Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2022-09-16 23:27:27 +02:00
Augustin Le Fèvre f0a16022a6 Add test to ensure it is possible to trigger native event (#1114) 2022-09-15 10:43:06 +02:00
Pierre Zimmermann aa103b6206 fix: prevent non editable textinputs from being updated through getByTestID (#1092)
* fix: prevent non editable textinputs from being updated through getByTestID

* refactor: add comment to explain double check in isTextInput function

* Update src/__tests__/fireEvent.test.tsx

* Update src/__tests__/fireEvent.test.tsx

Co-authored-by: pierrezimmermann <pierrez@nam.tech>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2022-09-13 17:03:54 +02:00
dependabot[bot] 72637c2a28 chore(deps-dev): bump @callstack/eslint-config from 12.0.2 to 13.0.1 (#1103)
* chore(deps-dev): bump @callstack/eslint-config from 12.0.2 to 13.0.1

Bumps [@callstack/eslint-config](https://github.com/callstack/eslint-config-callstack) from 12.0.2 to 13.0.1.
- [Release notes](https://github.com/callstack/eslint-config-callstack/releases)
- [Commits](https://github.com/callstack/eslint-config-callstack/commits)

---
updated-dependencies:
- dependency-name: "@callstack/eslint-config"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: run lint --fix

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2022-09-08 17:44:26 +02:00
dependabot[bot] 69baf3989e chore(deps-dev): bump react-native from 0.69.5 to 0.70.0 (#1097)
* chore(deps-dev): bump react-native from 0.69.5 to 0.70.0

Bumps [react-native](https://github.com/facebook/react-native) from 0.69.5 to 0.70.0.
- [Release notes](https://github.com/facebook/react-native/releases)
- [Changelog](https://github.com/facebook/react-native/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/react-native/compare/v0.69.5...v0.70.0)

---
updated-dependencies:
- dependency-name: react-native
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: update snapshots

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2022-09-08 17:39:36 +02:00
Maciej Jastrzebski 2c096fff99 feature: export options types and renderHook result type (#1091) 2022-09-06 12:54:39 +02:00
dependabot[bot] 669fd610aa chore(deps-dev): bump typescript from 4.7.4 to 4.8.2 (#1082)
* chore(deps-dev): bump typescript from 4.7.4 to 4.8.2

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.7.4 to 4.8.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.7.4...v4.8.2)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix: typescript update

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2022-08-26 22:25:45 +02:00
dependabot[bot] f5db461f80 chore(deps-dev): bump jest from 28.1.3 to 29.0.0 (#1076)
* chore(deps-dev): bump jest from 28.1.3 to 29.0.0

Bumps [jest](https://github.com/facebook/jest/tree/HEAD/packages/jest) from 28.1.3 to 29.0.0.
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/jest/commits/v29.0.0/packages/jest)

---
updated-dependencies:
- dependency-name: jest
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix: nuke snapshots

* chore: update pretty-format

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2022-08-25 15:35:16 +02:00
dependabot[bot] bfdaabc3e6 chore(deps-dev): bump @callstack/eslint-config from 11.0.0 to 12.0.2 (#950)
* chore(deps-dev): bump @callstack/eslint-config from 11.0.0 to 12.0.2

Bumps [@callstack/eslint-config](https://github.com/callstack/eslint-config-callstack) from 11.0.0 to 12.0.2.
- [Release notes](https://github.com/callstack/eslint-config-callstack/releases)
- [Commits](https://github.com/callstack/eslint-config-callstack/compare/v11.0.0...v12.0.2)

---
updated-dependencies:
- dependency-name: "@callstack/eslint-config"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: disable a11y eslint rules

* fix: formatting

* fix: flowcheck

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2022-08-09 10:31:31 +02:00
Maciej Jastrzebski ade9f33986 refactor: remove legacy wait for options support (#1018) 2022-07-20 14:32:37 +02:00
Maciej Jastrzebski 980b3df440 chore: reenable skipped byText tests (#1017) 2022-07-20 14:08:57 +02:00
Maciej Jastrzebski 9f3b31dd9d refactor: remove deprecated byA11yStates queries (#1015) 2022-07-20 12:33:19 +02:00
MattAgn 74318854b9 Organise a11y queries by predicate (#977)
* refactor: make Options generic type optionnal in queries

* refactor: extract byLabelText queries and its tests

* refactor: extract byA11yHint queries and its tests

* refactor: extract byRole queries and its tests

* refactor: extract byA11yState queries and its tests

* refactor: extract byA11yValue queries and its tests

* refactor: extract byA11yStates queries and its tests

* refactor: harmonize component declaration in queries testsx

* refactor: simplify error helpers in queries tests

* refactor: make error helpers more explicit

* chore: remove now unused makeA11yQueries

* refactor: rename AccessibilityStateKeyQueryParam to AccessibilityStateKeys

* refactor: rename param in a11yStates

* refactor: simplify matchObject

* refactor: fix namings in labelText

* refactor: fix namings in a11yHint

* refactor: fix queryAll namings'

* refactor: fix some namings in a11yState

* refactor: fix some namings in role

* refactor: fix some namings in a11yValue

* refactor: extract matchStringValue

* refactor: extract matchObject

* refactor: extract matchArrayValue

* test: add tests for the matchers

* refactor: simplify matchArrayValue to make it more explicit

* refactor: reorder imports and object keys

* refactor: update types

* refactor: small tweaks

* refactor: tweaks

* refactor: clarify matcher naming

* refactor: add missing aliases

* chore: fix ci timeout

* chore: revert jest timeout increase

* chore: revert timeout increase

* chore: fix ci tests

* chore: re-enable disabled tests

* chore: reduce jest paralelizaiton

* chore: ci tweaks

Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2022-07-20 11:37:04 +02:00
David Calhoun d2269f62b0 Trigger non-touch events on box-none targets (#906)
* Trigger non-touch events on box-none targets

Currently, this library disables _all_ events for a target with
`pointerEvents="box-none"`. This behavior is counter to how React Native
itself functions. This change continues to disable touch events, e.g.
`press`, for targets set to "box-none", but allows triggering non-touch
events, e.g. `layout`, `touchStart`.

* Event triggers target box-none View instead of child

This approach more closely aligns with the original failing test case.

* Rename events in test description

Attempt to better communicate the test is focused on ensuring that touch
events continue to trigger (e.g. `touchStart`), but the final event from
a touch tap does not trigger.
2022-07-19 11:56:01 +02:00
Maciej Jastrzebski 77bf93c5ad chore: update Jest to 28 (#1008)
* chore: update jest

* refactor: pass useFakeTimer config in tests

* refactor: remove unused code

* fix jest config unable to discover babel due to rootDir change

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2022-07-19 09:53:38 +02:00
Maciej Jastrzebski bdd8f75864 chore: update react-native to 0.69.1 (#1010)
* chore: update react-native deps

* refactor: split fake timer test to make it pass
2022-07-18 18:14:58 +02:00
Maciej Jastrzebski 63f7731a17 chore: update react-native to 0.68.2 (#1009)
* chore: update react-native to 0.68.2

* chore: update workflow node version to 14

* chore: fix flow

* chote: increase jest timeout
2022-07-18 17:28:37 +02:00