Open thanhtschoepe opened 1 year ago
npm i -D @testing-library/svelte jsdom vite-plugin-svelte-inline-compile svelte-inline-compile
.Add the following to your vite.config.{js,ts}
import { sveltekit } from '@sveltejs/kit/vite';
+import svelteInlineCompile from 'vite-plugin-svelte-inline-compile';
import { defineConfig } from 'vitest/config';
export default defineConfig({
The in tests you can do something like
```js
/**
* @vitest-environment jsdom
*/
import { describe, it, expect } from 'vitest';
import { render, screen } from '@testing-library/svelte';
import svelte from 'svelte-inline-compile'
describe('button', () => {
it('renders a button', () => {
render(svelte`<button>button</button>`)
expect(screen.getByRole('button').textContent).toEqual('button')
});
});
Let me know if that helps!
As title said, I'd like to know how I can install with a vite setup