
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
vitest-browser-vue
Advanced tools
Render Vue components in Vitest Browser Mode. This library follows testing-library
principles and exposes only locators and utilities that encourage you to write tests that closely resemble how your Vue components are used.
Requires vitest
and @vitest/browser
2.1.0 or higher.
import { render } from 'vitest-browser-vue'
import { expect, test } from 'vitest'
test('counter button increments the count', async () => {
const screen = render(Component, {
props: {
initialCount: 1,
}
})
await screen.getByRole('button', { name: 'Increment' }).click()
await expect.element(screen.getByText('Count is 2')).toBeVisible()
})
vitest-browser-vue
also automatically injects render
and cleanup
methods on the page
. Example:
// vitest.config.ts
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
// if the types are not picked up, add `vitest-browser-vue` to
// "compilerOptions.types" in your tsconfig or
// import `vitest-browser-vue` manually so TypeScript can pick it up
setupFiles: ['vitest-browser-vue'],
browser: {
name: 'chromium',
enabled: true,
},
},
})
import { page } from '@vitest/browser/context'
test('counter button increments the count', async () => {
const screen = page.render(Component, {
props: {
initialCount: 1,
}
})
screen.cleanup()
})
Unlike @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
.
@vue/test-utils
@testing-library/vue
FAQs
Render Vue components in Vitest Browser Mode
The npm package vitest-browser-vue receives a total of 9,856 weekly downloads. As such, vitest-browser-vue popularity was classified as popular.
We found that vitest-browser-vue demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.