{"id":15391906,"url":"https://github.com/skovhus/react-native-navigation-mock-render","last_synced_at":"2025-04-15T23:26:08.012Z","repository":{"id":57338582,"uuid":"117421700","full_name":"skovhus/react-native-navigation-mock-render","owner":"skovhus","description":"Enzyme render mock of wix/react-native-navigation – super fast integration test! 🚀","archived":false,"fork":false,"pushed_at":"2018-01-15T11:47:09.000Z","size":272,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-24T21:21:27.867Z","etag":null,"topics":["enzyme","jest","react-native","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/skovhus.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}},"created_at":"2018-01-14T10:44:32.000Z","updated_at":"2019-08-20T14:49:31.000Z","dependencies_parsed_at":"2022-09-04T14:21:43.430Z","dependency_job_id":null,"html_url":"https://github.com/skovhus/react-native-navigation-mock-render","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/skovhus%2Freact-native-navigation-mock-render","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skovhus%2Freact-native-navigation-mock-render/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skovhus%2Freact-native-navigation-mock-render/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skovhus%2Freact-native-navigation-mock-render/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skovhus","download_url":"https://codeload.github.com/skovhus/react-native-navigation-mock-render/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232670354,"owners_count":18558569,"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":["enzyme","jest","react-native","testing"],"created_at":"2024-10-01T15:13:26.913Z","updated_at":"2025-01-06T03:53:50.737Z","avatar_url":"https://github.com/skovhus.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003ereact-native-navigation-mock-render\u003c/h1\u003e\n\n  [![NPM Version](https://img.shields.io/npm/v/react-native-navigation-mock-render.svg?style=flat)](https://www.npmjs.com/package/react-native-navigation-mock-render)\n  [![Build Status](https://travis-ci.org/skovhus/react-native-navigation-mock-render.svg?branch=master)](https://travis-ci.org/skovhus/react-native-navigation-mock-render)\n  [![MIT License](https://img.shields.io/npm/l/react-native-navigation-mock-render.svg?style=flat-square)](https://github.com/skovhus/react-native-navigation-mock-render/blob/master/LICENSE)\n  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n\u003c/div\u003e\n\n**Work in progress, stay tuned.**\n\nThin node.js mock of [wix/react-native-navigation](https://github.com/wix/react-native-navigation) that makes it possible to write fast integration test including:\n- rendering of screens\n- life cycle methods\n- navigation between screens\n\nUses:\n- [react-native-mock-render](https://github.com/Root-App/react-native-mock-render)\n- [enzyme](https://github.com/airbnb/enzyme)\n- [jsdom](https://github.com/tmpvar/jsdom)\n\n## Prerequisite\n\n- `react-native` \u003e= 0.49\n- `react` \u003e= 16.0.0\n\n\n## Example usage with Jest\n\n```shell\nyarn add --dev react-native-navigation-mock-render jsdom@^11.5.1 enzyme@^3.3.0 enzyme-adapter-react-16@^1.1.1 react-native-mock-render@^0.0.19\n```\n\nBesides you need a version of `react-dom` matching your version of `react`.\n\n```javascript\n\nimport { Navigation } from 'react-native-navigation'\nimport 'react-native-navigation-mock-render/setup/enzyme-environment'\nimport { getEnzymeAppWrapper } from 'react-native-navigation-mock-render/mock/platform'\n\nimport { IntroScreen } from '../screens/Intro'\nimport startApp from '../index'\n\njest.mock('react-native-navigation/src/deprecated/platformSpecificDeprecated', () =\u003e\n  require.requireActual('react-native-navigation-mock-render/mock/platform')\n)\n\njest.mock('react-native-navigation/src/ScreenVisibilityListener', () =\u003e\n  require.requireActual(\n    'react-native-navigation-mock-render/mock/ScreenVisibilityListener'\n  )\n)\n\nconst wrapper = getEnzymeAppWrapper()\n\nconst flushAllPromises = () =\u003e\n  new Promise(resolve =\u003e setImmediate(resolve))\n\ndescribe('app integration test', () =\u003e {\n\n  it('shows main screen after stepping through intro', async () =\u003e {\n    startApp()\n\n    await flushAllPromises()\n\n    let screenId = await Navigation.getCurrentlyVisibleScreenId()\n    expect(screenId).toEqual('MyApp.Intro')\n\n    const introInstance = wrapper\n      .find(IntroScreen)\n      .first()\n      .instance()\n\n    introInstance.onAcceptTermsPressed()\n\n    await flushAllPromises()\n\n    screenId = await Navigation.getCurrentlyVisibleScreenId()\n    expect(screenId).toEqual('MyApp.MainScreen')\n  })\n})\n```\n\nSee more inside the `example/__tests__` folder.\n\n## Limitations\n\nStill early stages. First focus is apps using `startSingleScreenApp`.\n\nBesides:\n- not all `ScreenVisibilityListener` have been implemented\n- not all `Navigation` methods have been implemented (e.g. `startTabBasedApp`, `showContextualMenu`)\n\n\n## Contributing\n\nTo get started, run:\n\n\tyarn\n\nWhen developing:\n\n\tyarn run lint\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskovhus%2Freact-native-navigation-mock-render","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskovhus%2Freact-native-navigation-mock-render","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskovhus%2Freact-native-navigation-mock-render/lists"}