* 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>
* do not throw when event handler was not found
* remove unnecessary hasDescendandHandler
Co-authored-by: Pontus Lundin <pontus.lundin@klarna.com>
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
* capture global timers, use them in waitFor, tests+
* use real timers in flushMicroTasks
* test to show changes with modern timer mocks
* use enum-like object for timer modes
* fix tests
* remove default timer mode, add flow types
export other timer helpers, adjust tests and docs
* base waitFor on RTL implementation
* [jest] Capture and restore global promise
* [waitFor] Simulate intervals when using fake timers
* [tests] Fix waitForElementToBeRemoved
* cleanups; use more specific global
* rename globals to match others
Co-authored-by: Michael James Duminy <michael-james.duminy@klarna.com>
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
* refactor: extract method filterNodeByType
* feat: use makeQueries for byText
* feat: use makeQueries for byPlaceholderText
* feat: use makeQueries for byDisplayValue
* refactor: renamed method in queryAllByTestId
* refactor: rename method makeQuery to makeA11yQuery
the renaming is done to avoid any confusion with makeQueries which should be the new way to add new queries
* test: add test for errors for byTestId
* sort exports
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
* fix: make getByDisplayValue check the default value of text inputs
* fix: make getByDisplayValue only use defaultValue if value is undefined
if the value of TextInput is an empty string, then the TextInput will not use the defaultValue and display the empty string. Our tests now do the same
* refactor: add makeQueries functions
* refactor: use new query builders on byTestId
* rebase and rearrange to a bit
* add fixme
* refactor: make single function makeQueries
* doc: add TODO to do before end of pr
* fix: fix flow issue
* parametrize Queries
* chore: delete duplicated test
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
* chore: bump React Native to 0.64 RC
* Snapshot update
* Bumped node version to 12 on CI
* Removed removed supress_comment syntax from config
* codemod types-first
* Prettied files after codemod
* Added flow types to API returns
* don't return null from fireEvent handlers
* return ReactTestInstance instead of any
* fix render returning any
* less anys
* less anys
* simplify call type
* simplify
* add Flow to missing files, type debug better
Co-authored-by: Michał Parkitny <michal.parkitny@callstack.com>
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
* fix: add onMoveShouldSetResponder to element enabled checking
* Update src/fireEvent.js
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
* feat: export root test instance from render
* test: add tests for root test instance returned from render function
* docs: add description about root test instance returned from render function
* feat: change root export to container and wrap component in View if no wrapper defined
* docs: update description about container test instance returned from render function
* test: update tests for root test instance returned from render function
* test: clean up comments in tests
* feat: add react-native as peerDependency, clean up lint ignore for lines that was importing react-native
* revert adding default wrapper
* rework tests
* reword docs
* add testID checks
* add comments
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
* test showing the issue
* don't pass non-responder host elements as decsecendants
* linter fixs
* attempting to improve readability
* refactor: re-structure code for clarity & redability
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
* add the value expected in getBy error messages (e.g. "No instances found with text 'bla'")
* updated a11y test
* rename fullNoInstanceError to getNoInstancesFoundMessage
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
* addressing PR comments
* fixed lint error
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
* fix: Return closest Text matching a query
* Add test for another edge case
* Fix whitespaces
* adjust comment
* Update src/helpers/getByAPI.js
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
* update test
* use queryBy
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
* fix: package reference in docs
* fix: more references to package name
* Update README.md
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
* Update website/docs/GettingStarted.md
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
* Update website/docs/API.md
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
* 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>
* fix: modern jest timers
* treat modern timers as default, but be explicit in tests
* we're node-only
* rename to Thenable
* add clarifications; unify test names
* Update src/__tests__/auto-cleanup-skip.test.js
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
* feat: add "cleanup" function
* docs: add "cleanup" section
* feat: automatically call "cleanup" after each test
...if an "afterEach" global function is defined, and process.env.RTL_SKIP_AUTO_CLEANUP is falsy.
Taken from: https://github.com/testing-library/react-testing-library/blob/14670debd45236d2c5d0a61a83dadc72af1bef7c/src/index.js
* docs: mention automatic cleanup
* add within
* fix lint
* Updated tests, added auto-cleanup test
* Added ways to prevent auto cleanup
* Small fix
* Code review changes
* Update website/docs/API.md
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
* More changes
* Removed afterEach(cleanup) calls in examples
* Code cleanup
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
* Replaced getByTestId with fixed version
* Added tests
* Fixed flow-check
* Updated docs
* Fixed lint error
* Used getByTestId in unit tests instead of queryByTestId
* Updated negative checks in tests
* Added @testing-library/jest-native to devDependencies
* Tests for jest-native matchers
* Added @testing-library/jest-native install info
* Update README.md
* Update GettingStarted.md
* 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>
* chore: bump eslint config to latest (#308)
* chore: bump eslint config to latest
* lint fix
* lint pass
* use roles directly
* Trying to fix CI build
* Added $FlowFixMe for missing flow expect extensions
* Small doc fixes
* Clarified failing toHaveProps matcher tests
* Moved lint ignore for color literals to .eslintrc
* Updated toHaveProp tests to avoid strange `Button` behavior
* Updated yarn.lock
* Update README.md
* Update website/docs/GettingStarted.md
Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
* 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>