180 Commits

Author SHA1 Message Date
Maciej Jastrzebski 62a9b570fc feature: userEvent clear() (#1440)
* feat: implement clear()

* chore: add docs

* chore: fix lint

* refactor: remove redundant clearAllMocks

* feat: throw on disabled element

* refactor: tweak errors

* refactor: cleanup

* refactor: remove error on disabled element
2023-08-10 22:35:00 +02:00
Maciej Jastrzebski fd08a4cd2d chore: update docs (#1448) 2023-08-10 13:15:42 +02:00
Maciej Jastrzebski 3382867b13 chore: expose User Event in the exports and website (#1410)
* chore: expose User Event in the exports and website

* docs: tweaks, add beta notice

* chore: anotate fireEvent api

* docs: tweaks
2023-08-04 12:28:28 +02:00
Maciej Jastrzebski 574205aa93 feat: User Event type() (#1396)
* feat: userEvent type()

chore: restore tests

chore: more tests

chore: improve coverage

chore: moar tests

docs: improve the docs

chore: fix lint

refactor: code review changes

chore: fix lint

chore: tweak return type

refactor: flush microtasks after event

refactor: re-organize waits

refactor: improve dispatch event functions

refactor: remove flushMicroTasks calls

* chore: update snapshots

* chore: do not expose User Event docs yet

* refactor: simplify dispatchEvent code

* refactor: press

* refactor: move warn method up

* refactor: finishing touches

* docs: correct typos
2023-07-24 11:53:09 +02:00
Pierre Zimmermann 1f381772ca feat: userEvent.press (#1386)
* feat: create first version of userEvent.press

* feat: do not trigger press event when pointer events is disabled

* feat: make press events bubble up when trigerring a non touch responder

* tests: add test cases for userevent.press to check calls to onPressIn and onPressOut

* refactor: move userEvent.press tests in a dedicated test file

* feat: add pressDuration option for userEvent.press

* refactor: group test that check prop calls

* feat: add support for touchable opacity for userevent press

* feat: add support for Text

* feat: add support for TextInput for userEvent.press

* refactor: add some comments to explain pointer events api

* refactor: change the api of userEvent.press to make it async

* feat: add support for real timers for userEvent.press

* refactor: create a longPress api and remove duration option from press api

* feat: add warning for users when userEvent is used with real timers

* refactor: rewrite press using common user event code

* refactor: remove duplicate pointerEventEnabled method

* refactor: remove check on fake timers in user.press

* refactor: change order of functions in press file to have exports first

* feat: add delay before press

* feat: wait min press duration before calling onPressout for text and textInput

* chore: improve coverage

* feat: account for press duration when waiting for press out

* fix: wait for press duration also when pressing text or textinput

* docs: add documentation on press and longpress

* fix: check pointer events for Text and TextInput

* chore: fixes and tweaks on userEvent docs

* Update press doc based on review suggestion

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

* refactor: rename pressDuration option to duration

* Update longPress doc based on review suggestion

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

* refactor: use ts doc for isPointerEventsEnabled method

* refactor: rename file isPointerEventsEnabled to pointer-events

* refactor: split test in longPress in two

* refactor: use Date.now instead of new Date().getTime()

* refactor: also test payload of events for press and longpress

* refactor: fix typo in some longpress test names

* Update src/user-event/press/utils/warnAboutRealTimers.ts

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

* refactor: merge press and touch events

* fix: return after pressing text or textinput

* refactor: extract functions to trigger press on text/textInput

* refactor: use optional chaining

* feat: update warning when using userEvent with real timers

* refactor: check on press test that longPress is not called

* refactor: test directly warnings logged with real timers without mocking function

---------

Co-authored-by: pierrezimmermann <pierrez@nam.tech>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2023-07-17 17:27:42 +02:00
Maciej Jastrzebski 8c22290fd2 Update GettingStarted.md 2023-05-10 12:18:57 +02:00
Maciej Jastrzebski dab444d6dd feat: User Event core code (#1405)
* chore: extract user event common parts

* chore: stub press/type implementations

* chore: add sample tests

* refactor: tweaks

* chore: improve test coverage

* chore: more sample tests

* refactor: remove Date.now touch event timestamp

* chore: hide new docs from website

* feat: expose direct access
2023-05-10 10:33:00 +02:00
Josh Justice 9906ab743f Fix a11y typo (#1408)
* Fix a11y typo

* Add missing (deprecated)
2023-05-09 12:04:00 +02:00
Youssouf EL AZIZI 74acd58137 docs: add config example for pnpm (#1400)
* Add config example for pnpm 

While using `pnpm` as package manger `transformIgnorePatterns` should refernce to package inside `.pnpm` folder.
[source](https://jestjs.io/docs/configuration#transformignorepatterns-arraystring)

* Update website/docs/ReactNavigation.md

---------

Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2023-05-02 14:00:09 +02:00
Stephen Hanson 4ac2833ae6 fix: docs link to GitHub (#1390) 2023-04-21 21:44:10 +02:00
Maciej Jastrzebski 7b02f510d6 chore: fix migration guide role prop naming (#1382) 2023-04-05 18:21:07 +02:00
Josh Justice 7eb1114dc9 Fix typo in "derived" in v12 migration guide (#1376) 2023-04-04 20:06:35 +02:00
renovate[bot] 7628005b7e fix(deps): update all minor & patch deps (#1363)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-15 18:57:38 +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
Pierre Zimmermann 43e02e443a docs: update docs on custom jest preset (#1316)
* docs: update docs on custom jest preset

* docs: flip conditions on modern timers and react native version

* Update README.md

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

* Update title in readme for custom jest preset

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

---------

Co-authored-by: pierrezimmermann <pierrez@nam.tech>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2023-02-17 14:37:08 +01:00
Maciej Jastrzebski 3739c89d32 chore: upgrade docusaurus 2.3.1 (#1336)
* chore: upgrade docusaurus
* chore: upgrade website react
2023-02-17 12:37:46 +01:00
renovate[bot] 4487b62e1b chore(deps): update node.js to v8.17.0 (#1326)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-16 12:20:45 +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
dependabot[bot] 15e2db7869 chore(deps): bump http-cache-semantics from 4.1.0 to 4.1.1 in /website (#1303)
Bumps [http-cache-semantics](https://github.com/kornelski/http-cache-semantics) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/kornelski/http-cache-semantics/releases)
- [Commits](https://github.com/kornelski/http-cache-semantics/compare/v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: http-cache-semantics
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-08 11:49:34 +01:00
Maciej Jastrzebski 8bd19520bf chore: deprecate some a11y queries (#1226) 2023-01-28 22:31:56 +01:00
dependabot[bot] b6b31a2a66 chore(deps): bump ua-parser-js from 0.7.31 to 0.7.33 in /website (#1294)
Bumps [ua-parser-js](https://github.com/faisalman/ua-parser-js) from 0.7.31 to 0.7.33.
- [Release notes](https://github.com/faisalman/ua-parser-js/releases)
- [Changelog](https://github.com/faisalman/ua-parser-js/blob/master/changelog.md)
- [Commits](https://github.com/faisalman/ua-parser-js/compare/0.7.31...0.7.33)

---
updated-dependencies:
- dependency-name: ua-parser-js
  dependency-type: indirect
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-26 11:58:18 +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
Maciej Jastrzebski 9019eed3d1 chore: deploy website to GH pages (#1282)
* chore: deploy website to gh pages

* chore: fix deploy script

* chore: fix deploy script

* chore: tweaks

* chore: tweaks
2023-01-19 10:34:13 +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 71d5040697 chore: update examples to use toBeOnTheScreen() (#1267) 2023-01-03 17:52:31 +01:00
Maciej Jastrzebski aa92b77bbf fix: add deprecation notice for *ByA11yState and *ByA11yValue queries (#1269) 2023-01-03 11:15:08 +01:00
Maciej Jastrzebski 9ec12705e7 docs: improve findBy docs by adding information about screen.debug() (#1268) 2023-01-03 11:07:30 +01:00
dependabot[bot] 0467479fbe chore(deps): bump json5 from 2.2.1 to 2.2.2 in /website (#1266)
Bumps [json5](https://github.com/json5/json5) from 2.2.1 to 2.2.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v2.2.1...v2.2.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-30 10:46:43 +01:00
Pierre Zimmermann ad125ea98c docs: rewrite documentation on waitFor (#1233)
Co-authored-by: pierrezimmermann <pierrez@nam.tech>
2022-12-06 22:13:18 +01:00
Maciej Jastrzebski 45302ea122 docs: use includeHiddenElements option name instead of hidden (#1246) 2022-12-01 16:32:02 +01:00
dependabot[bot] fa34289cf8 chore(deps): bump loader-utils from 2.0.3 to 2.0.4 in /website (#1227)
Bumps [loader-utils](https://github.com/webpack/loader-utils) from 2.0.3 to 2.0.4.
- [Release notes](https://github.com/webpack/loader-utils/releases)
- [Changelog](https://github.com/webpack/loader-utils/blob/v2.0.4/CHANGELOG.md)
- [Commits](https://github.com/webpack/loader-utils/compare/v2.0.3...v2.0.4)

---
updated-dependencies:
- dependency-name: loader-utils
  dependency-type: indirect
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-16 10:34:06 +01:00
Maciej Jastrzebski 527ea62623 feat: *ByRole a11y value option (#1210) 2022-11-15 16:53:10 +01:00
dependabot[bot] e3a76cae35 chore(deps): bump loader-utils from 2.0.0 to 2.0.3 in /website (#1217)
Bumps [loader-utils](https://github.com/webpack/loader-utils) from 2.0.0 to 2.0.3.
- [Release notes](https://github.com/webpack/loader-utils/releases)
- [Changelog](https://github.com/webpack/loader-utils/blob/v2.0.3/CHANGELOG.md)
- [Commits](https://github.com/webpack/loader-utils/compare/v2.0.0...v2.0.3)

---
updated-dependencies:
- dependency-name: loader-utils
  dependency-type: indirect
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-15 16:14:00 +01:00
Maciej Jastrzebski 87a715bd69 Update API.md
Fix link
2022-11-15 11:47:53 +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
Maciej Jastrzebski bfb3498e39 docs: testing environment (#1195)
* docs: testing environment

* fix: links

* docs: link from FAQ

* Update TestingEnvironment.md

* Apply suggestions from code review

Co-authored-by: Pierre Zimmermann <64224599+pierrezimmermannbam@users.noreply.github.com>
Co-authored-by: Augustin Le Fèvre <augustin.le-fevre@klarna.com>

* docs: code review changes

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
Co-authored-by: Pierre Zimmermann <64224599+pierrezimmermannbam@users.noreply.github.com>
Co-authored-by: Augustin Le Fèvre <augustin.le-fevre@klarna.com>
2022-10-31 16:09:21 +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
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
Maciej Jastrzebski 28aa750aea docs: add typedefs for queries (#1175) 2022-10-18 08:01:33 +02:00
Josh Justice 190df67b16 Eslint plugin docs typos (#1157) 2022-10-02 22:32:37 +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 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 9892c21d2d docs: document render options (#1129) 2022-09-20 11:56:55 +02:00
Gabiveu1574 1089c3ea45 corrected typo on line 44 from targes to targets (#1108) 2022-09-09 08:28:50 +02:00