{"id":16959256,"url":"https://github.com/chriskalmar/mock-mirror","last_synced_at":"2025-04-11T22:08:34.877Z","repository":{"id":226410115,"uuid":"768607775","full_name":"chriskalmar/mock-mirror","owner":"chriskalmar","description":"Mock Mirror","archived":false,"fork":false,"pushed_at":"2024-03-12T13:20:47.000Z","size":225,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T22:08:25.521Z","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/chriskalmar.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}},"created_at":"2024-03-07T11:57:04.000Z","updated_at":"2024-03-30T02:32:34.000Z","dependencies_parsed_at":"2024-10-19T05:17:52.392Z","dependency_job_id":null,"html_url":"https://github.com/chriskalmar/mock-mirror","commit_stats":{"total_commits":105,"total_committers":1,"mean_commits":105.0,"dds":0.0,"last_synced_commit":"0319642f9bb871dc63343538c3dd20549bfb4acc"},"previous_names":["chriskalmar/mock-mirror"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriskalmar%2Fmock-mirror","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriskalmar%2Fmock-mirror/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriskalmar%2Fmock-mirror/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriskalmar%2Fmock-mirror/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chriskalmar","download_url":"https://codeload.github.com/chriskalmar/mock-mirror/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248487712,"owners_count":21112191,"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":[],"created_at":"2024-10-13T22:44:35.723Z","updated_at":"2025-04-11T22:08:34.802Z","avatar_url":"https://github.com/chriskalmar.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align='center'\u003e\n  \u003cimg width='480px' height='200px' src='https://github.com/chriskalmar/mock-mirror/assets/8336893/7ab47463-87ed-40f5-9ca7-e0a959d87fdd'\u003e\n\u003c/div\u003e\n\n---\n\n\u003cdiv align='center'\u003e\n  \u003ca href=\"https://www.npmjs.com/package/mock-mirror\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/mock-mirror?style=plastic\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/mock-mirror\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/mock-mirror\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/chriskalmar/mock-mirror/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/chriskalmar/mock-mirror\" /\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n# Mock Mirror\n\nMock services behind your backend during integration tests.\n\n## Install\n\nInstall **Mock Mirror** as a dev dependency:\n\n```bash\nnpm install -D mock-mirror\n```\n\n## Why\n\nWhen writing integration tests, there are numerous ways to mock responses from your backend. This can be done directly in your tests (for example, in **Playwright**, **Cypress**, etc.) or by using tools like **Mock Service Worker**.\n\nBut what if your backend connects to other services and you would like to test your frontend and backend together while mocking those service responses?\n\nWith **Mock Mirror** you get a tiny prgrammable server which can be fed with mocks directly within your tests.\n\n### Example\n\n```ts\ndescribe('user', () =\u003e {\n  it('should be able to fetch users from the user service', async ({ page }) =\u003e {\n    await mockMirror(async ({ addRoutes, scope }) =\u003e {\n      // Add a route to mock the user service\n      await addRoutes([\n        {\n          pathPattern: '/api/users/*',\n          response: {\n            id: 777,\n            username: 'johnwick',\n            firstname: 'John',\n            lastname: 'Wick',\n          },\n        },\n      ]);\n\n      // This will hit the backend, which will then connect to the mocked user service\n      await page.goto('http://localhost:3000/user/detail/777');\n\n      await expect(page.getByText('Welcome, John Wick')).toBeVisible();\n    });\n  });\n});\n```\n\n## Development\n\nTo start the development server run:\n\n```bash\nbun run dev\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchriskalmar%2Fmock-mirror","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchriskalmar%2Fmock-mirror","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchriskalmar%2Fmock-mirror/lists"}