{"id":36655790,"url":"https://github.com/sdstolworthy/vue-composable-tester","last_synced_at":"2026-01-12T10:18:19.749Z","repository":{"id":44619808,"uuid":"455293942","full_name":"sdstolworthy/vue-composable-tester","owner":"sdstolworthy","description":"A simple function useful for testing composable state functions commonly found in Vue 3 applications.","archived":false,"fork":false,"pushed_at":"2022-02-06T00:13:14.000Z","size":540,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T10:41:30.783Z","etag":null,"topics":["composable","vue","vue3","vue3-composition-api","vuejs","vuejs3"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vue-composable-function-tester","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/sdstolworthy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-03T19:07:25.000Z","updated_at":"2022-08-21T10:13:17.000Z","dependencies_parsed_at":"2022-09-05T05:01:31.053Z","dependency_job_id":null,"html_url":"https://github.com/sdstolworthy/vue-composable-tester","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/sdstolworthy/vue-composable-tester","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdstolworthy%2Fvue-composable-tester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdstolworthy%2Fvue-composable-tester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdstolworthy%2Fvue-composable-tester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdstolworthy%2Fvue-composable-tester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sdstolworthy","download_url":"https://codeload.github.com/sdstolworthy/vue-composable-tester/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdstolworthy%2Fvue-composable-tester/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28338107,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["composable","vue","vue3","vue3-composition-api","vuejs","vuejs3"],"created_at":"2026-01-12T10:18:19.650Z","updated_at":"2026-01-12T10:18:19.737Z","avatar_url":"https://github.com/sdstolworthy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Unit Tests](https://github.com/sdstolworthy/vue-composable-tester/actions/workflows/tests.yaml/badge.svg)](https://github.com/sdstolworthy/vue-composable-tester/actions/workflows/tests.yaml)\n\n[![Publish Package to NPM](https://github.com/sdstolworthy/vue-composable-tester/actions/workflows/publish-to-npm.yaml/badge.svg)](https://github.com/sdstolworthy/vue-composable-tester/actions/workflows/publish-to-npm.yaml)\n\n[![Coverage Status](https://coveralls.io/repos/github/sdstolworthy/vue-composable-tester/badge.svg?branch=main)](https://coveralls.io/github/sdstolworthy/vue-composable-tester?branch=main)\n\n# Vue Composable Function Tester\n\nVue Composable Function Tester simplifies testing Composable Functions in Vue 3.\n\n## Installation\n\n`npm install --save-dev vue-composable-function-tester`\n\n`yarn add --dev vue-composable-function-tester`\n\n## Usage\n\nVue Composable Function Tester is intended to make unit testing Vue Composable Functions\n(analogous to React Hooks) straightforward.\n\nTo use the tester, simply call `mountComposableFunction` with a callback that returns your composable function.\nUnder the hood, the tester will mount the composable into a Vue component, and return a reference\nto the reactive values. In addition, the tester returns a `nextTick` method that allows you to make assertions after the state has updated.\n\nCredit should be given to ktsn, the author of [Vue Composable Tester](https://github.com/ktsn/vue-composable-tester) for his work on a similar solution.\n\nHere's an example of testing a simple counter composable [based on a popular Vue tutorial](https://vueschool.io/articles/vuejs-tutorials/what-is-a-vue-js-composable/)\n\n```typescript\ntest(\"updates after invoking a setter method\", async () =\u003e {\n  const useCount = () =\u003e {\n    const count = ref(0);\n    const increment = () =\u003e count.value++;\n\n    return {\n      count: readonly(count),\n      increment,\n    };\n  };\n  const { data, nextTick } = mountComposableFunction(() =\u003e useCount());\n  expect(data.count.value).toBe(0);\n  data.increment();\n  await nextTick();\n  expect(data.count.value).toBe(1);\n});\n```\n\nHere is a simple example of testing a composable that updates state based on the resolution of a promise.\n\nNotice that the `nextTick()` method is called for each tick of the state that is expected from the composable.\n\n```typescript\nexport function useAsynchronousLoader\u003cT\u003e(promiseCreator: () =\u003e Promise\u003cT\u003e) {\n  const isLoading = ref(false);\n  const data = ref\u003cT\u003e();\n  const error = ref\u003cobject\u003e();\n  isLoading.value = true;\n  promiseCreator()\n    .then((newData) =\u003e {\n      data.value = newData;\n    })\n    .catch((e) =\u003e {\n      error.value = e;\n    })\n    .finally(() =\u003e {\n      isLoading.value = false;\n    });\n  return {\n    isLoading,\n    data,\n    error,\n  };\n}\n\nit(\"Reacts to a resolving promise\", async () =\u003e {\n  const resolvedData = {\n    hello: \"world\",\n  };\n  const promise = Promise.resolve(resolvedData);\n  const composable = mountComposableFunction(() =\u003e\n    useAsynchronousLoader(() =\u003e promise)\n  );\n  await composable.nextTick();\n  expect(composable.data.isLoading.value).toBe(true);\n  await promise;\n  await composable.nextTick();\n  expect(composable.data.data.value).toStrictEqual(resolvedData);\n  await composable.nextTick();\n  expect(composable.data.isLoading.value).toBe(false);\n});\n```\n\n## Want to help?\n\nIf you think you can help make this package better, please open an issue or a pull request and start a conversation.\n\nDo you have a novel example that you want to share? Open an issue so we can add it to the Readme!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdstolworthy%2Fvue-composable-tester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsdstolworthy%2Fvue-composable-tester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdstolworthy%2Fvue-composable-tester/lists"}