Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature proposal: Vite plugin #359

Closed
mcous opened this issue Apr 21, 2024 · 1 comment · Fixed by #362
Closed

Feature proposal: Vite plugin #359

mcous opened this issue Apr 21, 2024 · 1 comment · Fixed by #362
Labels
enhancement New feature or request released

Comments

@mcous
Copy link
Collaborator

mcous commented Apr 21, 2024

Overview

This library requires three bits of setup to work correctly with Vitest

  1. Browser bundle resolution
  2. Testing library cleanup
  3. jest-dom matchers (optional, but pretty much everyone wants it)

Setting these up is a bit fiddly and results in inbound issues in this repository

Proposal

The most effective method at resolving (1) appears to be setting up a simple Vite plugin. A Vite plugin would also be capable of configuring (2) and maybe even (3). I think we should add a Vite plugin as an export to this library.

Usage (e.g. with SvelteKit)

// vite.config.ts
import { defineConfig } from 'vite'
import { svelteTesting } from '@testing-library/svelte/vite-plugin'
import { svelteKit } from '@sveltejs/kit/vite'

export default defineConfig({
  plugins: [svelteKit(), svelteTesting()],
})
// @testing-library/svelte/vite-plugin
export const svelteTesting = ({
  resolveBrowser = true,
  autoCleanup = true,
  extendExpect = true,
}) => ...

Related issues

Copy link

🎉 This issue has been resolved in version 5.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
1 participant