Simple and complete ReblendJS DOM testing utilities that encourage good testing practices.
Reblend Testing Library provides lightweight utilities for testing ReblendJS components. It encourages tests that focus on user interactions and DOM output, not implementation details.
npm install --save-dev reblend-testing-library @testing-library/dom @testing-library/jest-dom
- Requires Node.js >= 20
- Peer dependencies:
reblendjs
,@testing-library/dom
import { render, fireEvent, screen } from 'reblend-testing-library';
import '@testing-library/jest-dom';
function Counter() {
const [count, setCount] = Reblend.useState(0);
return (
<>
<button onClick={() => setCount(count + 1)}>{count}</button>
{count ? 'Clicked!' : 'Click the button!'}
</>
);
}
test('increments counter', async () => {
render(<Counter />);
const button = screen.getByRole('button');
expect(button).toHaveTextContent('0');
fireEvent.click(button);
expect(button).toHaveTextContent('1');
expect(screen.getByText('Clicked!')).toBeInTheDocument();
});
- Works with ReblendJS components and hooks
- Encourages user-centric testing
- Integrates with @testing-library/dom and @testing-library/jest-dom
- Supports async utilities like
waitFor
,findBy*
, etc.
render(ui, options)
: Render a ReblendJS component to the DOMfireEvent
: Simulate user eventsscreen
: Global queries for DOM elementswaitFor
,waitForElementToBeRemoved
: Async utilities for waiting on DOM changes
See the API docs for more details.
- All React/ReactDOM references have been removed
- Use
reblendjs
and Reblend Testing Library utilities in your tests - Most React Testing Library patterns are supported, but use ReblendJS components/hooks
See CONTRIBUTING.md for guidelines.
MIT ยฉ Emmanuel Paul Elom
For more examples and advanced usage, see the docs or open an issue if you have questions.