@lynx-js/react/testing-library
ReactLynx Testing Library is a simple and complete ReactLynx unit testing library that encourages good testing practices.
Inspired completely by react-testing-library
Similar to react-testing-library, this library is designed to test your ReactLynx components in the same way you would test React components using react-testing-library.
Setup
Rstest
Setup rstest with @lynx-js/react/testing-library/rstest-config.
Recommended for library projects:
Use withLynxConfig when you want to reuse your app's lynx.config.ts:
Difference between withLynxConfig and withDefaultConfig:
withLynxConfig: app-oriented. Loads yourlynx.config.tsand converts it to rstest config, so rspeedy/lynx settings are reused in tests.withDefaultConfig: library-oriented. Only applies testing-library defaults (jsdom, setup files, globals) and lets you provide the rest viamodifyRstestConfig.
Then you can start writing tests and run them with rstest!
For more usage detail, see https://rstest.rs/
Vitest
Setup vitest:
Then you can start writing tests and run them with vitest!
createVitestConfig is still supported for backward compatibility, but is deprecated.
Usage
💡 Since our testing environment (@lynx-js/testing-environment) is based on jsdom, You may also be interested in installing @testing-library/jest-dom so you can use
the custom jest matchers.
Examples
See our examples for more usage.
Credits
- Testing Library for the testing utilities and good practices for React testing.
Namespaces
Classes
Interfaces
- ByRoleOptions
- Config
- ConfigFn
- DefaultNormalizerOptions
- LogRolesOptions
- MatcherOptions
- NormalizerOptions
- PrettyDOMOptions
- Queries
- QueryOptions
- RenderHookOptions
- RenderHookResult
- RenderOptions
- SelectorMatcherOptions
- Suggestion
- waitForOptions
Type Aliases
- AllByAttribute
- AllByBoundAttribute
- AllByRole
- AllByText
- BoundFunction
- BoundFunctions
- BuiltQueryMethods
- ByRoleMatcher
- CreateFunction
- CreateObject
- ElementTree
- EventType
- FindAllBy
- FindAllByBoundAttribute
- FindAllByRole
- FindAllByText
- FindBy
- FindByBoundAttribute
- FindByRole
- FindByText
- FireFunction
- FireObject
- GetAllBy
- GetBy
- GetByBoundAttribute
- GetByRole
- GetByText
- GetErrorFunction
- Match
- Matcher
- MatcherFunction
- Method
- NormalizerFn
- Query
- QueryArgs
- QueryBy
- QueryByAttribute
- QueryByBoundAttribute
- QueryByRole
- QueryByText
- QueryMethod
- RenderResult
- Screen
- Variant
- WithSuggest
Variables
Functions
- act
- buildQueries
- cleanup
- computeHeadingLevel
- configure
- findAllByAltText
- findAllByDisplayValue
- findAllByLabelText
- findAllByPlaceholderText
- findAllByRole
- findAllByTestId
- findAllByText
- findAllByTitle
- findByAltText
- findByDisplayValue
- findByLabelText
- findByPlaceholderText
- findByRole
- findByTestId
- findByText
- findByTitle
- getAllByAltText
- getAllByDisplayValue
- getAllByLabelText
- getAllByPlaceholderText
- getAllByRole
- getAllByTestId
- getAllByText
- getAllByTitle
- getByAltText
- getByDisplayValue
- getByLabelText
- getByPlaceholderText
- getByRole
- getByTestId
- getByText
- getByTitle
- getConfig
- getDefaultNormalizer
- getElementError
- getNodeText
- getQueriesForElement
- getRoles
- getSuggestedQuery
- isInaccessible
- logDOM
- logRoles
- prettyDOM
- queryAllByAltText
- queryAllByDisplayValue
- queryAllByLabelText
- queryAllByPlaceholderText
- queryAllByRole
- queryAllByTestId
- queryAllByText
- queryAllByTitle
- queryByAltText
- queryByDisplayValue
- queryByLabelText
- queryByPlaceholderText
- queryByRole
- queryByTestId
- queryByText
- queryByTitle
- render
- renderHook
- waitFor
- waitForElementToBeRemoved
waitSchedule