{"id":20416107,"url":"https://github.com/khanghoang/react-redux-mock","last_synced_at":"2025-07-01T04:38:17.754Z","repository":{"id":151265053,"uuid":"84584279","full_name":"khanghoang/react-redux-mock","owner":"khanghoang","description":"Mock react-redux for testing","archived":false,"fork":false,"pushed_at":"2018-02-05T19:12:35.000Z","size":62,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T11:21:32.406Z","etag":null,"topics":["mock","react","redux","testing"],"latest_commit_sha":null,"homepage":"","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/khanghoang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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,"zenodo":null}},"created_at":"2017-03-10T17:26:07.000Z","updated_at":"2020-02-18T09:09:27.000Z","dependencies_parsed_at":"2023-04-23T18:46:33.730Z","dependency_job_id":null,"html_url":"https://github.com/khanghoang/react-redux-mock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khanghoang%2Freact-redux-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khanghoang%2Freact-redux-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khanghoang%2Freact-redux-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khanghoang%2Freact-redux-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/khanghoang","download_url":"https://codeload.github.com/khanghoang/react-redux-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248602304,"owners_count":21131615,"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":["mock","react","redux","testing"],"created_at":"2024-11-15T06:18:41.835Z","updated_at":"2025-04-12T17:06:45.132Z","avatar_url":"https://github.com/khanghoang.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redux-react-mock\nMock the `react-redux` package.\n\n### Installation\n\n```\nyarn add --dev react-redux-mock\n```\n\n```\nnpm install --save-dev react-redux-mock\n```\n\n### Usage\n\nLet's assume that you have an `connected` component with this structure.\n```\nimport React from 'react';\nimport { connect } from 'react-react';\n\nconst Text = ({ content }) =\u003e \u003cp\u003e{content}\u003c/p\u003e;\nconst contentSelector = state =\u003e state.content;\n\nconst ConnectedText = compose(\n  connect(state =\u003e {\n    content: contentSelector(state),\n  }),\n)(Text);\n\nexport default ConnectedText;\n```\n\nThis is how you can test the component above with `react-redux-mock`?\n```\njest.mock('react-redux', () =\u003e require('react-redux-mock'));\nimport { __setState } from 'react-redux';\nimport { mount } from 'enzyme';\n\ndescribe('Text component', () =\u003e {\n  it('renders correctly', () =\u003e {\n    __setState({\n      content: 'foo',\n    });\n    const component = mount(\u003cConnectedText /\u003e);\n    expect(component).toMatchSnapshot();\n  });\n});\n```\n\nNotice that you can render the `connected` component itself without\ndefining what is the store and the `Provider` component.\n\n### Have question?\nI'm happy to answer all questions from you at [@khanght](https://twitter.com/khanght).   \nHappy coding, forks!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhanghoang%2Freact-redux-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhanghoang%2Freact-redux-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhanghoang%2Freact-redux-mock/lists"}