rut alternatives and similar libraries
Based on the "Test" category.
Alternatively, view rut alternatives based on common mentions on social networks and blogs.
-
https://github.com/microsoft/playwright
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API. -
react-testing-library
🐐 Simple and complete React DOM testing utilities that encourage good testing practices. -
carte-blanche
An isolated development space with integrated fuzz testing for your components. See them individually, explore them in different states and quickly and confidently develop them. -
redux-test-recorder
a redux middleware to automatically generate tests for reducers through ui interaction -
unexpected-react
Plugin for http://unexpected.js.org to enable testing the full React virtual DOM, and also the shallow renderer
SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of rut or a related project?
README
Rut
Rut is a DOM-less React testing library that aims to be lightweight, encourage great testing practices, and reduce flakiness and code smells. It is a wrapper and abstraction around react-test-renderer that simplifies the test writing process, while doing all the hard work behind the scenes.
import { render } from 'rut-dom';
import Input, { InputProps } from '../src/Input';
describe('<Input />', () => {
it('renders an input field', () => {
const { root, update } = render<InputProps>(<Input name="rut" value="foo" />);
expect(root).toHaveProp('name', 'rut');
expect(root).toHaveValue('foo');
expect(root).not.toBeDisabled();
update({ disabled: true });
expect(root).toBeDisabled();
});
});
The rut
package provides core functionality for adapters to expand upon. For example, a DOM
adapter for react-dom
, a mobile native adapter for react-native
, or even a custom adapter unique
to your application.
Features
- Type safe by design. Test with confidence.
- First-class async support. Wait for async calls to finish before returning a rendered result. (Experimental)
- Deep
act()
integration. Let Rut do the heavy lifting. - Update a component with new props, children, or a completely new element.
- Unmount a component to verify cleanup and destructor based logic.
- Dispatch DOM level events with a mocked synthetic event (and propagation coming soon!).
- Wrap all renders with a defined wrapping component and or
React.StrictMode
. - Apply pre-built mocks for robust and accurate testing.
- Utilize an array of pre-built matchers for easily querying, expecting, and asserting.
Best Practices
Encourages the Arrange-Act-Assert testing pattern.
Arrange: Renders the entire component tree (instead of shallow) for a more accurate representation of your component. Requires fetches, events, contexts, and more, to be properly mocked or setup before hand.
Act: With no direct access to state or internals, it forces you to interact with your tree in the same manner your user would. Dispatch events to toggle states or execute handlers, like a form submission.
Assert: Test your expectations using pre-built matchers for common testing scenarios and patterns while avoiding implementation details.
Requirements
- React 16.9+ (Rut v1)
- React 17+ (Rut v2)
- Jest or another testing framework