Skip to content

Feature proposal: Vite plugin #359

Closed
@mcous

Description

@mcous

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions