{"id":18408913,"url":"https://github.com/vitest-dev/vitest-browser-vue","last_synced_at":"2025-04-07T09:33:25.430Z","repository":{"id":252402563,"uuid":"838810172","full_name":"vitest-dev/vitest-browser-vue","owner":"vitest-dev","description":"Render Vue components in Vitest Browser Mode","archived":false,"fork":false,"pushed_at":"2024-09-26T12:16:01.000Z","size":295,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-30T09:33:44.799Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vitest-browser-vue","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vitest-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-08-06T11:42:07.000Z","updated_at":"2024-10-14T11:01:29.000Z","dependencies_parsed_at":"2024-08-09T15:04:12.805Z","dependency_job_id":"0d91406e-b4af-49ef-b809-87043e96d26f","html_url":"https://github.com/vitest-dev/vitest-browser-vue","commit_stats":null,"previous_names":["vitest-dev/vitest-browser-vue"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitest-dev%2Fvitest-browser-vue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitest-dev%2Fvitest-browser-vue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitest-dev%2Fvitest-browser-vue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitest-dev%2Fvitest-browser-vue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitest-dev","download_url":"https://codeload.github.com/vitest-dev/vitest-browser-vue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223275973,"owners_count":17118257,"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-11-06T03:22:17.711Z","updated_at":"2025-04-07T09:33:25.416Z","avatar_url":"https://github.com/vitest-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vitest-browser-vue\n\nRender Vue components in Vitest Browser Mode. This library follows [`testing-library` principles](https://testing-library.com/docs/guiding-principles/) and exposes only [locators](https://vitest.dev/guide/browser/locators) and utilities that encourage you to write tests that closely resemble how your Vue components are used.\n\nRequires `vitest` and `@vitest/browser` 2.1.0 or higher.\n\n```ts\nimport { render } from 'vitest-browser-vue'\nimport { expect, test } from 'vitest'\n\ntest('counter button increments the count', async () =\u003e {\n  const screen = render(Component, {\n    props: {\n      initialCount: 1,\n    }\n  })\n\n  await screen.getByRole('button', { name: 'Increment' }).click()\n\n  await expect.element(screen.getByText('Count is 2')).toBeVisible()\n})\n```\n\n`vitest-browser-vue` also automatically injects `render` and `cleanup` methods on the `page`. Example:\n\n```ts\n// vitest.config.ts\nimport { defineConfig } from 'vitest/config'\n\nexport default defineConfig({\n  test: {\n    // if the types are not picked up, add `vitest-browser-vue` to\n    // \"compilerOptions.types\" in your tsconfig or\n    // import `vitest-browser-vue` manually so TypeScript can pick it up\n    setupFiles: ['vitest-browser-vue'],\n    browser: {\n      name: 'chromium',\n      enabled: true,\n    },\n  },\n})\n```\n\n```ts\nimport { page } from '@vitest/browser/context'\n\ntest('counter button increments the count', async () =\u003e {\n  const screen = page.render(Component, {\n    props: {\n      initialCount: 1,\n    }\n  })\n\n  screen.cleanup()\n})\n```\n\nUnlike `@testing-library/vue`, `vitest-browser-vue` cleans up the component before the test starts instead of after, so you can see the rendered result in your UI. To avoid auto-cleanup, import the `render` function from `vitest-browser-vue/pure`.\n\n## Configuration\n\nYou can change the global configuration by modifying the `config` export. You can import it from both `vitest-browser-vue` and `vitest-browser-vue/pure`. See [documentation](https://test-utils.vuejs.org/api/#config).\n\n```js\nimport { config } from 'vitest-browser-vue'\n\nconfig.global.mocks = {\n  $t: text =\u003e text\n}\n```\n\n## Special thanks\n\n- Powered by [`@vue/test-utils`](https://github.com/vuejs/test-utils/)\n- Inspired by [`@testing-library/vue`](https://github.com/testing-library/vue-testing-library)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitest-dev%2Fvitest-browser-vue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitest-dev%2Fvitest-browser-vue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitest-dev%2Fvitest-browser-vue/lists"}