{"id":13422590,"url":"https://github.com/milesj/rut","last_synced_at":"2025-03-15T12:30:45.204Z","repository":{"id":47395994,"uuid":"202250146","full_name":"milesj/rut","owner":"milesj","description":"⚛️ React testing made easy. Supports DOM and custom renderers.","archived":true,"fork":false,"pushed_at":"2021-09-01T20:40:10.000Z","size":6427,"stargazers_count":16,"open_issues_count":28,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-30T01:38:03.308Z","etag":null,"topics":["react","rut","testing","unit-test"],"latest_commit_sha":null,"homepage":"https://ruttest.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/milesj.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"ko_fi":"milesjohnson"}},"created_at":"2019-08-14T01:31:29.000Z","updated_at":"2023-11-11T16:27:24.000Z","dependencies_parsed_at":"2022-09-14T15:02:02.489Z","dependency_job_id":null,"html_url":"https://github.com/milesj/rut","commit_stats":null,"previous_names":[],"tags_count":68,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milesj%2Frut","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milesj%2Frut/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milesj%2Frut/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milesj%2Frut/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/milesj","download_url":"https://codeload.github.com/milesj/rut/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243730977,"owners_count":20338747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react","rut","testing","unit-test"],"created_at":"2024-07-30T23:00:48.389Z","updated_at":"2025-03-15T12:30:44.675Z","avatar_url":"https://github.com/milesj.png","language":"TypeScript","readme":"# Rut\n\n[![Build Status](https://github.com/milesj/rut/workflows/Build/badge.svg)](https://github.com/milesj/rut/actions?query=branch%3Amaster)\n[![npm version](https://badge.fury.io/js/rut.svg)](https://www.npmjs.com/package/rut)\n[![npm deps](https://david-dm.org/milesj/rut.svg?path=packages/rut)](https://www.npmjs.com/package/rut)\n\nRut is a DOM-less React testing library that aims to be lightweight, encourage great testing\npractices, and reduce flakiness and code smells. It is a wrapper and abstraction around\n[react-test-renderer](https://reactjs.org/docs/test-renderer.html) that simplifies the test writing\nprocess, while doing all the hard work behind the scenes.\n\n```tsx\nimport { render } from 'rut-dom';\nimport Input, { InputProps } from '../src/Input';\n\ndescribe('\u003cInput /\u003e', () =\u003e {\n  it('renders an input field', () =\u003e {\n    const { root, update } = render\u003cInputProps\u003e(\u003cInput name=\"rut\" value=\"foo\" /\u003e);\n\n    expect(root).toHaveProp('name', 'rut');\n    expect(root).toHaveValue('foo');\n    expect(root).not.toBeDisabled();\n\n    update({ disabled: true });\n\n    expect(root).toBeDisabled();\n  });\n});\n```\n\nThe `rut` package provides core functionality for adapters to expand upon. For example, a DOM\nadapter for `react-dom`, a mobile native adapter for `react-native`, or even a custom adapter unique\nto your application.\n\n## Features\n\n- Type safe by design. Test with confidence.\n- First-class async support. Wait for async calls to finish before returning a rendered result.\n  _(Experimental)_\n- Deep [`act()`](https://reactjs.org/docs/testing-recipes.html#act) integration. Let Rut do the\n  heavy lifting.\n- Update a component with new props, children, or a completely new element.\n- Unmount a component to verify cleanup and destructor based logic.\n- Dispatch DOM level events with a mocked synthetic event (and propagation coming soon!).\n- Wrap all renders with a defined wrapping component and or `React.StrictMode`.\n- Apply pre-built mocks for robust and accurate testing.\n- Utilize an array of pre-built matchers for easily querying, expecting, and asserting.\n\n## Best Practices\n\nEncourages the [Arrange-Act-Assert](http://wiki.c2.com/?ArrangeActAssert) testing pattern.\n\n_Arrange:_ Renders the entire component tree (instead of shallow) for a more accurate representation\nof your component. Requires fetches, events, contexts, and more, to be properly mocked or setup\nbefore hand.\n\n_Act:_ With no direct access to state or internals, it forces you to interact with your tree in the\nsame manner your user would. Dispatch events to toggle states or execute handlers, like a form\nsubmission.\n\n_Assert:_ Test your expectations using pre-built matchers for common testing scenarios and patterns\nwhile avoiding implementation details.\n\n## Requirements\n\n- React 16.9+ (Rut v1)\n- React 17+ (Rut v2)\n- Jest or another testing framework\n\n## Documentation\n\n[https://ruttest.dev](https://ruttest.dev)\n","funding_links":["https://ko-fi.com/milesjohnson"],"categories":["Dev Tools"],"sub_categories":["Test"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilesj%2Frut","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmilesj%2Frut","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilesj%2Frut/lists"}