{"id":13702867,"url":"https://github.com/uki00a/fresh-testing-library","last_synced_at":"2025-06-25T05:06:30.778Z","repository":{"id":176945347,"uuid":"651192327","full_name":"uki00a/fresh-testing-library","owner":"uki00a","description":"Utilities for testing fresh apps","archived":false,"fork":false,"pushed_at":"2025-03-20T05:52:55.000Z","size":132,"stargazers_count":23,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-24T07:40:59.138Z","etag":null,"topics":["deno","fresh","testing-library"],"latest_commit_sha":null,"homepage":"https://deno.land/x/fresh_testing_library","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/uki00a.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":"2023-06-08T17:51:03.000Z","updated_at":"2025-03-20T05:52:56.000Z","dependencies_parsed_at":"2024-04-06T07:24:21.453Z","dependency_job_id":"95971e65-3a2c-4d41-8170-cee208f4ca51","html_url":"https://github.com/uki00a/fresh-testing-library","commit_stats":null,"previous_names":["uki00a/fresh-testing-library"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/uki00a/fresh-testing-library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uki00a%2Ffresh-testing-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uki00a%2Ffresh-testing-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uki00a%2Ffresh-testing-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uki00a%2Ffresh-testing-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uki00a","download_url":"https://codeload.github.com/uki00a/fresh-testing-library/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uki00a%2Ffresh-testing-library/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261808047,"owners_count":23212687,"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","fresh","testing-library"],"created_at":"2024-08-02T21:00:44.769Z","updated_at":"2025-06-25T05:06:30.745Z","avatar_url":"https://github.com/uki00a.png","language":"TypeScript","readme":"# fresh-testing-library\n\n`fresh-testing-library` provides various utilitites to write unit/integration\ntests for fresh apps.\n\n## Features\n\n- Support testing of handlers/middlewares/islands/routes\n- Jest-compatible `expect()` API\n- Emulate Partial rendering, etc. as much as possible\n\n## Installation\n\nAt first, you need to add this library as a dependency to `deno.json` or\n`import_map.json`:\n\n```jsonc\n  // ...\n  \"imports\": {\n    \"$std/\": \"https://deno.land/std@0.190.0/\",\n    \"🏝️/\": \"./islands/\",\n    \"$fresh/\": \"https://deno.land/x/fresh@1.2.0/\",\n    // ...\n\n    // Add the following lines to your deno.json\n    \"$fresh-testing-library\": \"https://deno.land/x/fresh_testing_library@$MODULE_VERSION/mod.ts\",\n    \"$fresh-testing-library/\": \"https://deno.land/x/fresh_testing_library@$MODULE_VERSION/\"\n  },\n  // ...\n```\n\n## Permissions\n\nThis package requires several permissions.\n\nSee [docs/permissions](docs/permissions.md) for details.\n\n## Usage\n\n### Testing island components\n\n`$fresh-testing-library/components.ts` is a thin wrapper to\n[@testing-library/preact](https://github.com/testing-library/preact-testing-library)\nand\n[@testing-library/user-event](https://github.com/testing-library/user-event).\nThis module can be used to test island components.\n\nSee [examples/island-component.test.tsx](examples/island-component.test.tsx) for\nusage.\n\n### `expect()` API\n\n`$fresh-testing-library/expect.ts` provides the `expect()` API. It is based on\n[expect](https://github.com/jestjs/jest/tree/v29.7.0/packages/expect) and\n[jest-mock](https://github.com/jestjs/jest/tree/v29.7.0/packages/jest-mock)\npackages, so it is compatible with Jest.\n\n```ts\nimport { expect, fn } from \"$fresh-testing-library/expect.ts\";\n\nexpect(1).toBe(1);\n\nconst spy = fn();\nexpect(spy).not.toBeCalled();\nspy();\nexpect(spy).toBeCalled();\n\n// Matchers provided by `@testing-library/jest-dom` are also supported.\nexpect(expect(null).toBeInTheDocument).toBeTruthy();\n```\n\n### Testing fresh middlewares\n\nYou can test fresh middlewares using `createFreshContext()` API. See\n[examples/middleware.test.ts](examples/middleware.test.ts) for usage.\n\n### Testing fresh handlers\n\nYou can also test fresh handlers using `createFreshContext()` API. See\n[examples/handler.test.ts](examples/handler.test.ts) for usage.\n\n### Testing async route components\n\nYou can test async route components by combining `createFreshContext()` and\n`render()`. See\n[examples/async-component.test.tsx](examples/async-component.test.tsx) for\ndetails.\n\n### Submodules\n\nThis library provides submodules so that only necessary functions can be\nimported.\n\n```ts\nimport { createFreshContext } from \"$fresh-testing-library/server.ts\";\n\nimport {\n  cleanup,\n  render,\n  setup,\n  userEvent,\n} from \"$fresh-testing-library/components.ts\";\n\nimport { expect } from \"$fresh-testing-library/expect.ts\";\n```\n\n## Recipes\n\n### Testing a component which uses relative `fetch()`\n\nBy combining [MSW](https://github.com/mswjs/msw) and `--location` flag, you can\ntest a component which calls `fetch()` with a relative URL.\n\nFirst, add the following setting to `deno.json`:\n\n```jsonc\n{\n  \"imports\": {\n    // Add the following line:\n    \"msw\": \"npm:msw@2.0.8\"\n  }\n}\n```\n\nNow you can use MSW! See [examples/msw.test.ts](examples/msw.test.ts) for\ndetails.\n","funding_links":[],"categories":["Modules"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuki00a%2Ffresh-testing-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuki00a%2Ffresh-testing-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuki00a%2Ffresh-testing-library/lists"}