{"id":15673390,"url":"https://github.com/satyarohith/metch","last_synced_at":"2025-05-08T03:15:43.690Z","repository":{"id":62421989,"uuid":"349517710","full_name":"satyarohith/metch","owner":"satyarohith","description":"A Deno module to mock fetch() calls.","archived":false,"fork":false,"pushed_at":"2021-05-24T12:38:14.000Z","size":6,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-08T03:15:38.699Z","etag":null,"topics":["deno","fetch","mock","testing"],"latest_commit_sha":null,"homepage":"https://deno.land/x/metch","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/satyarohith.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":"2021-03-19T18:20:10.000Z","updated_at":"2024-04-28T16:35:10.000Z","dependencies_parsed_at":"2022-11-01T17:32:05.936Z","dependency_job_id":null,"html_url":"https://github.com/satyarohith/metch","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satyarohith%2Fmetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satyarohith%2Fmetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satyarohith%2Fmetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satyarohith%2Fmetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/satyarohith","download_url":"https://codeload.github.com/satyarohith/metch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252990004,"owners_count":21836668,"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":["deno","fetch","mock","testing"],"created_at":"2024-10-03T15:40:24.714Z","updated_at":"2025-05-08T03:15:43.673Z","avatar_url":"https://github.com/satyarohith.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# metch\n\nA Deno module to mock `fetch()`.\n\n```ts\nimport { mockFetch, unMockFetch } from \"https://deno.land/x/metch/mod.ts\";\nimport { assertEquals } from \"https://deno.land/std@0.90.0/testing/asserts.ts\";\n\nDeno.test(\"mocks fetch() as expected\", async () =\u003e {\n  const request1 = new Request(\"https://example.com\");\n  const expectedResponse1 = new Response(\"\u003chtml\u003e example.com \u003c/html\u003e\", {\n    status: 200,\n    headers: {\n      \"content-type\": \"text/html\",\n    },\n  });\n\n  const request2 = new Request(\"https://example.rest\");\n  const expectedResponse2 = new Response(\n    JSON.stringify({ message: \"example\" }),\n    {\n      status: 200,\n      headers: {\n        \"content-type\": \"text/html\",\n      },\n    },\n  );\n\n  // Pass a request object and a response object which\n  // will be used to respond to fetch().\n  await mockFetch(request1, expectedResponse1.clone());\n\n  // Call again to mock more requests.\n  await mockFetch(request2, expectedResponse2.clone());\n\n  const response1 = await fetch(request1);\n  const response2 = await fetch(request2);\n\n  assertEquals(response1.status, expectedResponse1.status);\n  assertEquals(await response1.text(), await expectedResponse1.text());\n  assertEquals(\n    response1.headers.get(\"content-type\"),\n    expectedResponse1.headers.get(\"content-type\"),\n  );\n\n  assertEquals(response2.status, expectedResponse2.status);\n  assertEquals(await response2.text(), await expectedResponse2.text());\n  assertEquals(\n    response2.headers.get(\"content-type\"),\n    expectedResponse2.headers.get(\"content-type\"),\n  );\n\n  // Restore original fetch().\n  unMockFetch();\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatyarohith%2Fmetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsatyarohith%2Fmetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatyarohith%2Fmetch/lists"}