{"id":20565742,"url":"https://github.com/phenax/react-test-render-fns","last_synced_at":"2026-04-29T22:03:03.856Z","repository":{"id":57346252,"uuid":"179988419","full_name":"phenax/react-test-render-fns","owner":"phenax","description":"A collection of utility functions made from react-test-renderer with high level support for react hooks.","archived":false,"fork":false,"pushed_at":"2021-01-05T14:03:22.000Z","size":91,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T14:50:50.126Z","etag":null,"topics":["hooks","js","react","react-test-renderer","testing"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phenax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-07T15:54:23.000Z","updated_at":"2021-01-05T14:03:24.000Z","dependencies_parsed_at":"2022-09-17T23:21:07.272Z","dependency_job_id":null,"html_url":"https://github.com/phenax/react-test-render-fns","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phenax/react-test-render-fns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Freact-test-render-fns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Freact-test-render-fns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Freact-test-render-fns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Freact-test-render-fns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phenax","download_url":"https://codeload.github.com/phenax/react-test-render-fns/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phenax%2Freact-test-render-fns/sbom","scorecard":{"id":730857,"data":{"date":"2025-08-11","repo":{"name":"github.com/phenax/react-test-render-fns","commit":"808c49769e6062188a5fc45046f4dd1d749dc668"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/7 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"68 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-mh2h-6j8q-x246","Warn: Project is vulnerable to: GHSA-5q88-cjfq-g2mh","Warn: Project is vulnerable to: GHSA-xp63-6vf5-xf3v","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6","Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9","Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f","Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-pc5p-h8pf-mvwp","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-7wpw-2hjm-89gp","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9","Warn: Project is vulnerable to: GHSA-w7rc-rwvf-8q5r","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T14:22:09.911Z","repository_id":57346252,"created_at":"2025-08-22T14:22:09.912Z","updated_at":"2025-08-22T14:22:09.912Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32445555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T20:22:27.477Z","status":"ssl_error","status_checked_at":"2026-04-29T20:22:26.507Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["hooks","js","react","react-test-renderer","testing"],"created_at":"2024-11-16T04:38:55.976Z","updated_at":"2026-04-29T22:03:03.841Z","avatar_url":"https://github.com/phenax.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-test-render-fns\n\n\u003e [OUTDATED: Please use [react-testing-library](https://github.com/testing-library/react-testing-library) instead]\n\nA collection of utility functions made from react-test-renderer with high level support for react hooks.\n\n[![CircleCI](https://img.shields.io/circleci/project/github/phenax/react-test-render-fns/master.svg?style=for-the-badge)](https://circleci.com/gh/phenax/react-test-render-fns)\n[![Codecov](https://img.shields.io/codecov/c/github/phenax/react-test-render-fns.svg?style=for-the-badge)](https://codecov.io/gh/phenax/react-test-render-fns)\n\n\n## Motivation\nEnzyme is usually very slow with version releases and react is way to quick. So we need something that can stay with the latest react version without breaking on lack of support for new node types. This project doesn't make any assumtions about the node type so its free from cases that break enzyme. In case that something does break due to a new react api, we can easily fix it due to the composible nature of the api and adding new features in the library is super easy as well.\n\nAlso, WE HAVE SUPPORT FOR HOOKS!! While enzyme is busy lagging three versions behind on support, we are ready with hooks.\n\n\n## Usage\n\n### Mount your Component\nYou can use `mount` function to mount your components.\n```js\nimport { mount } from 'react-test-render-fns';\n\ndescribe('Stuff', () =\u003e {\n  it('should mount', () =\u003e {\n    mount(\u003cYourComponent /\u003e);\n  });\n});\n```\n\n\n### Render your Component for snapshot testing\nYou have `render` (similar to `mount`) to render your components. The rest of the api follows snapshot testing as you would with react-test-renderer.\n\n\n### Find your component inside a mounted node\n\n```js\nimport { mount } from 'react-test-render-fns';\n\ndescribe('Stuff', () =\u003e {\n  it('should have #myElem', () =\u003e {\n    const $node = mount(\u003cYourComponent /\u003e);\n    expect($node.findAll(n =\u003e n.props.id === 'myElem')).toHaveLength(1);\n  });\n  // Looks shit so we have a shorthand for that\n  it('should have #myElem', () =\u003e {\n    const $node = mount(\u003cYourComponent /\u003e);\n    expect($node.findAll(byId('myElem'))).toHaveLength(1);\n    const $div = $node.find(byId('myElem'));\n  });\n});\n```\n\n\n### Find filter helpers\nPassing a function and working with the nodes manually is very low level and not something we should be concerned about while writing test cases. So there are a few filter helpers included in the collection. The reason why we are avoiding findByType, etc methods provided by react-test-renderer, is because of the following reasons -\n- Consistency (allowing us to create many custom filters like this one)\n- Extensibility. In case we get a node type that has to be worked around while filtering.\n- Composition. We can compose multiple filters together (Eg - `compose(byType(Link), byId('paymentButton'))`)\n\n* **byType** - Select by component\n```js\nconst linkNode = node.find(byType(Link));\n```\n\n* **byTestSelector** - Select by a node's test selector\n```js\nconst linkNode = node.find(byTestSelector('some-button')); // Selects stuff like \u003cdiv data-test-selector=\"some-button\" /\u003e\n```\n\n* **byDisplayName** - Select by component display name\n```js\nconst linkNode1 = node.find(byDisplayName('Link'));\nconst linkNode2 = node.find(byDisplayName('Link', false)); // To exclude matching function names\n```\n\n* **byId** - Select by id attribute\n```js\nconst nameNode = node.find(byId('userName'));\n```\n\n* **byProp** - Select by id attribute\n```js\nconst nameNode = node.find(byProp('name')); // Prop name exists\nconst rameshNode = node.find(byProp('name', 'ramesh')); // Prop name exists and name === 'ramesh'\nconst rameshNode = node.find(byProp('data-user-name', 'ramesh')); // Data attributes\n\nconst nameNode = node.find(byProp('id', 'userName')); // Equivalent to byId('userName')\n```\n\n\n### Get data from node\n\n* text - Get the text being rendered\n```js\nconst myCompNode = node.find(byType(MyComp));\nexpect(text(myCompNode)).toBe('Hello world');\n```\n\n* getProp - Get a prop from the node\n```js\nconst myImage = node.find(byId('myImage'));\nexpect(getProp('src', myImage)).toBe('http://example.com/image.png');\n```\n\n* firstChild - Get the first child node in the tree\n```js\nconst img = firstChild(node.find(byType(MyImage)));\n```\n\n* getState, setState - Getter and setter for state\nDEPRECATED: Try to avoid these. This is only for class components and can be avoided in most cases by simulating/triggering the real event instead of messing with the state directly.\n```js\nconst counter = node.find(byType(Counter));\nsetState(s =\u003e ({ count: s.count++ }), counter);\nsetState(s =\u003e ({ count: s.count++ }), counter);\nsetState(s =\u003e ({ count: s.count++ }), counter);\nexpect(getState('count', counter)).toBe(3);\n```\n\n\n### Simulate events\nYou can simulate an event using `simulate` function.\nNOTE: This does not emulate browser event but instead just calls the on* handler function.\n\n```js\nimport { simulate, createEvent } from 'react-test-render-fns';\n\nconst clickHandler = jest.fn();\n\nconst node = mount(\u003cdiv\u003e\u003cButton onClick={clickHandler}\u003eClick me\u003c/Button\u003e\u003c/div\u003e);\nconst myBtn = node.find(byType(Button));\nsimulate(new MouseEvent('click'), myBtn);\n\nexpect(clickHandler).toHaveBeenCalled();\n```\nYou can also use `createEvent` instead of `new MouseEvent` in case you dont care about the event type much\n\n\n### Testing a component with react hooks\nBy default, the library support hooks i.e. `mount`, `render`, `simulate`, etc are all wrapped in `withAct` but there are cases where you may want to call an update in the state manually. For those cases, this library exposes 2 functions - `withAct` and `act`.\n\n* **act** - This is a low level, synchronous re-export of the act function which allows you to run something immediately with update awareness.\n\n* **withAct** - This is a higher order function that wraps around a function and returns a function that can be called without worrying about the state updates the function causes.\n\nIf you see a warning saying `An update to null inside a test was not wrappedin act(...)`, you can solve it by wrapping the synchronous code causing an update with `act` or `withAct` function to get rid of the error.\n\n```js\n// withAct\nconst callMyUpdater = withAct(() =\u003e fnThatUpdatesState());\ncallMyUpdater();\n\n// act\nact(() =\u003e {\n  fnThatUpdatesState(); // function wrapped with act should not have a return value\n});\n```\n\n* **runAllTimers** - This functions allows you to resolve any pending timers immediately and synchronously. Its basically a hooks friendly wrapper around `jest.runAllTimers` so you need to call `jest.useFakeTimers()` in any file using this function.\n\n\n## TODO\nThis is a list of stuff that is in the pipeline for the library. (Question mark at the end means it's a maybe)\n\n- [ ] `byQuerySelector` filter to allow using query selectors. (Preffered way to do this right now is by composing multiple filters together. `compose(byType('div'), byId('helloworld'))`)?\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphenax%2Freact-test-render-fns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphenax%2Freact-test-render-fns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphenax%2Freact-test-render-fns/lists"}