{"id":22076495,"url":"https://github.com/codecademy/component-test-setup","last_synced_at":"2025-09-14T22:41:57.239Z","repository":{"id":48774985,"uuid":"307391826","full_name":"Codecademy/component-test-setup","owner":"Codecademy","description":"Standardized test setup methods for React components.","archived":false,"fork":false,"pushed_at":"2024-07-09T17:26:46.000Z","size":172,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-09-13T14:56:34.234Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/Codecademy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-26T14:03:11.000Z","updated_at":"2025-04-04T03:03:35.000Z","dependencies_parsed_at":"2024-06-19T22:46:05.958Z","dependency_job_id":"356868f9-c302-4a59-b552-699705028895","html_url":"https://github.com/Codecademy/component-test-setup","commit_stats":{"total_commits":27,"total_committers":5,"mean_commits":5.4,"dds":0.5555555555555556,"last_synced_commit":"31cca290d6bb30ae28fb6239625364d57bcb0941"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Codecademy/component-test-setup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codecademy%2Fcomponent-test-setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codecademy%2Fcomponent-test-setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codecademy%2Fcomponent-test-setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codecademy%2Fcomponent-test-setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Codecademy","download_url":"https://codeload.github.com/Codecademy/component-test-setup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codecademy%2Fcomponent-test-setup/sbom","scorecard":{"id":31626,"data":{"date":"2025-08-11","repo":{"name":"github.com/Codecademy/component-test-setup","commit":"cc7f214b5853736c5b74a377643d59bbc8da4c38"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":5,"reason":"Found 15/28 approved changesets -- score normalized to 5","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":"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":10,"reason":"no dangerous workflow patterns detected","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":"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":"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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/publish.yml:7: update your workflow using https://app.stepsecurity.io/secureworkflow/Codecademy/component-test-setup/publish.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/publish.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/Codecademy/component-test-setup/publish.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/push.yml:7: update your workflow using https://app.stepsecurity.io/secureworkflow/Codecademy/component-test-setup/push.yml/main?enable=pin","Info:   0 out of   3 third-party GitHubAction dependencies pinned"],"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":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Warn: no topLevel permission defined: .github/workflows/push.yml:1","Info: no jobLevel write permissions found"],"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 18 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"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-14T19:14:53.132Z","repository_id":48774985,"created_at":"2025-08-14T19:14:53.132Z","updated_at":"2025-08-14T19:14:53.132Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275180196,"owners_count":25419065,"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","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-30T22:14:53.110Z","updated_at":"2025-09-14T22:41:57.214Z","avatar_url":"https://github.com/Codecademy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛠 component-test-setup\n\n[![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io)\n![TypeScript: Strict](https://img.shields.io/badge/typescript-strict-brightgreen.svg)\n[![NPM version](https://badge.fury.io/js/component-test-setup.svg)](http://badge.fury.io/js/component-test-setup)\n[![Circle CI](https://img.shields.io/circleci/build/github/Codecademy/component-test-setup.svg)](https://circleci.com/gh/Codecademy/component-test-setup)\n[![Join the chat at https://gitter.im/Codecademy/component-test-setup](https://badges.gitter.im/Codecademy/component-test-setup.svg)](https://gitter.im/Codecademy/component-test-setup?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nStandardized test setup methods for React components.\n\nTired of copy and pasting default prop templates for React component tests?\nUse this cute little package with React Testing Library to standardize your component setups.\n\n\u003e 🧠 This library is a _very_ small wrapper on top of RTL, and exists only to help standardize test setup behavior.\n\n## Usage\n\n```shell\nnpm install component-test-setup --save-dev\n```\n\nFor RTL, this library provides a `setup*` function that takes in:\n\n1. Your React component class or function\n2. Any prop defaults for the component _(optional)_\n\nThat function returns a `render*` function that takes in any more props and returns:\n\n- The library's rendered equivalent: `view` for RTL\n- `props`: The computed props the component rendered with.\n\n### React Testing Library\n\nUse `setupRtl` to create a `renderView` function.\nIt returns a `view` result from RTL and a `props` object of the computed props used to render.\n\n```js\nimport { setupRtl } from \"component-test-setup\";\n\nimport { MyComponent } from \"./MyComponent\";\n\nconst renderView = setupRtl(MyComponent, {\n  someProp: \"value\",\n});\n\ndescribe(\"MyComponent\", () =\u003e {\n  it(\"does a thing\", () =\u003e {\n    const { props, view } = renderView({\n      someProp: \"otherProp\",\n    });\n\n    view.getByText(props.someProp);\n  });\n});\n```\n\n#### RTL `options`\n\nThe `setupRtl` API in particular allows a `.options` function on the returned `renderView` function to set the RTL [`RenderOptions`](https://testing-library.com/docs/react-testing-library/api#render-options).\n\n```ts\nconst { view } = renderView(MyComponent).options({\n  wrapper: AllTheProviders,\n});\n```\n\n### Enzyme\n\nPrevious versions of this library supported Enzyme, but with the upgrade to React-18 and Enzyme nop longer being supported,\nthis library has moved to a place of no longer supporting it either.\n\nFor Enzyme support, please check older major versions of this library.\n\n### Updating Props\n\nOften you'd like to test lifecycle methods/hooks and `component-test-setup` is written to help accommodate that.\n\nThe `update` method returned in the `render*` method:\n\n```js\nconst renderView = setupRtl(MyComponent, {\n  someProp: \"value\",\n});\n\ndescribe(\"MyComponent\", () =\u003e {\n  it(\"does a thing\", () =\u003e {\n    const { view, update } = renderView({\n      some: \"otherProp\",\n    });\n\n    update({ someProp: \"another-value\" });\n\n    view.getByText(\"another-value\"); // It has been updated to render with the new someProp value\n  });\n});\n```\n\nPlease note: This currently _does not_ update the `props` object that's returned in the `render*` method. It will be locked into whatever the initial completed props were for the first render.\n\n### TypeScript Usage\n\n`component-test-setup` is written in TypeScript and generally type safe.\n\n- Props passed to components are typed as the component's props.\n- If a subset of required props are passed as defaults, the returned `render*` function will require only remaining required props.\n\n```ts\ntype MyComponentProps = {\n  requiredA: string;\n  requiredB: string;\n};\n\ndeclare const MyComponent: React.ComponentType\u003cMyComponentProps\u003e;\n\nconst renderView = setupRtl(MyComponent, {\n  requiredA: \"a\",\n});\n\ndescribe(\"MyComponent\", () =\u003e {\n  it(\"does a thing\", () =\u003e {\n    const { props, view } = renderView({\n      requiredB: \"b\",\n    });\n\n    view.getByText(props.someProp);\n  });\n});\n```\n\n- It is also set up to understand which of the required props have already been passed and which ones have not, allowing you to bypass sending anything at all into the `render*` method if you've already passed everything it needs:\n\n```ts\ntype MyComponentProps = {\n  requiredA: string;\n  requiredB: string;\n};\n\ndeclare const MyComponent: React.ComponentType\u003cMyComponentProps\u003e;\n\nconst renderView = setupRtl(MyComponent, {\n  requiredA: \"a\",\n  requiredB: \"b\",\n});\n\ndescribe(\"MyComponent\", () =\u003e {\n  it(\"does a thing\", () =\u003e {\n    const { props, view } = renderView();\n\n    view.getByText(props.someProp);\n  });\n});\n```\n\n- And of course, you may always provide overrides and/or optional props into your `render*` methods:\n\n```ts\ntype MyComponentProps = {\n  requiredA: string;\n  optional?: string;\n};\n\ndeclare const MyComponent: React.ComponentType\u003cMyComponentProps\u003e;\n\nconst renderView = setupRtl(MyComponent, {\n  requiredA: \"a\",\n});\n\ndescribe(\"MyComponent\", () =\u003e {\n  it(\"does a thing\", () =\u003e {\n    const { props, view } = renderView({\n      requiredA: \"override\",\n      optional: \"I don't need to be here, but I wanna be\",\n    });\n\n    view.getByText(props.someProp);\n  });\n});\n```\n\n_Heck yes._ 🤘\n\n## Development\n\nRequires:\n\n- [Node.js](https://nodejs.org) \u003e12\n- [Yarn](https://yarnpkg.com/en)\n\nAfter [forking the repo from GitHub](https://help.github.com/articles/fork-a-repo):\n\n```shell\ngit clone https://github.com/\u003cyour-name-here\u003e/component-test-setup\ncd component-test-setup\nyarn\n```\n\n### Publishing New Versions\n\nCI will automatically publish a new version when it sees a new version tag.\nLocally, you can trigger this if you have admin permissions:\n\n```shell\ngit checkout main\nnpm version \u003cpatch|minor|major\u003e\ngit push\n```\n\n### Contribution Guidelines\n\nWe'd love to have you contribute!\nCheck the [issue tracker](https://github.com/Codecademy/component-test-setup/issues) for issues labeled [`accepting prs`](https://github.com/Codecademy/component-test-setup/issues?utf8=%E2%9C%93\u0026q=is%3Aissue+is%3Aopen+label%3A%22accepting+prs%22) to find bug fixes and feature requests the community can work on.\nIf this is your first time working with this code, the [`good first issue`](https://github.com/Codecademy/component-test-setup/issues?utf8=%E2%9C%93\u0026q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+) label indicates good introductory issues.\n\nPlease note that this project is released with a [Contributor Covenant](https://www.contributor-covenant.org).\nBy participating in this project you agree to abide by its terms.\nSee [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecademy%2Fcomponent-test-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodecademy%2Fcomponent-test-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecademy%2Fcomponent-test-setup/lists"}