Skip to content

Commit

Permalink
Get minimal vitest working with SvelteKit
Browse files Browse the repository at this point in the history
  • Loading branch information
amosjyng committed Oct 10, 2023
1 parent b551e4c commit 388142a
Show file tree
Hide file tree
Showing 5 changed files with 903 additions and 3 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.20.4",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/svelte": "^4.0.3",
"jsdom": "^22.1.0",
"svelte": "^4.0.5",
"svelte-check": "^3.4.3",
"tslib": "^2.4.1",
Expand Down
1 change: 1 addition & 0 deletions src/Demo.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Demo URL: </p>
11 changes: 11 additions & 0 deletions src/Demo.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { expect, it } from "vitest";
import "@testing-library/jest-dom";
import { render, screen } from "@testing-library/svelte";
import Demo from "./Demo.svelte";

it("can render demo", async () => {
const { container } = render(Demo);
const paragraph = container.querySelector("p");
expect(paragraph).toHaveTextContent("Demo URL:")
});

4 changes: 3 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { defineConfig } from 'vitest/config';
export default defineConfig({
plugins: [sveltekit()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
include: ['src/**/*.{test,spec}.{js,ts}'],
globals: true,
environment: 'jsdom',
}
});
Loading

0 comments on commit 388142a

Please sign in to comment.