diff --git a/src/pages/__tests__/DashboardPage.test.tsx b/src/pages/__tests__/DashboardPage.test.tsx new file mode 100644 index 0000000..440198b --- /dev/null +++ b/src/pages/__tests__/DashboardPage.test.tsx @@ -0,0 +1,8 @@ +import { render, screen } from '@testing-library/react' +import { DashboardPage } from '../DashboardPage' +import { expect, test } from 'vitest' + +test('renders dashboard headline', () => { + render() + expect(screen.getByText(/Välkommen till HemHub/i)).toBeInTheDocument() +}) diff --git a/tsconfig.app.json b/tsconfig.app.json index 66ca809..52cd593 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -27,5 +27,12 @@ "baseUrl": ".", "paths": { "@/*": ["src/*"] } }, - "include": ["src"] + "include": ["src/**/*"], + "exclude": [ + "src/**/*.test.ts", + "src/**/*.test.tsx", + "src/**/*.spec.ts", + "src/**/*.spec.tsx", + "src/**/__tests__/**" + ], } diff --git a/vitest.config.ts b/vitest.config.ts index 08031ce..6478f3c 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,7 +1,12 @@ - import { defineConfig } from 'vitest/config' +import { defineConfig } from 'vitest/config' +import react from '@vitejs/plugin-react' import tsconfigPaths from 'vite-tsconfig-paths' export default defineConfig({ - plugins: [tsconfigPaths()], - test: { environment: 'jsdom', setupFiles: ['./vitest.setup.ts'] }, + plugins: [react(), tsconfigPaths()], // 👈 viktigt + test: { + environment: 'jsdom', + setupFiles: ['./vitest.setup.ts'], + globals: true, + }, }) diff --git a/vitest.setup.ts b/vitest.setup.ts index e69de29..c1d2755 100644 --- a/vitest.setup.ts +++ b/vitest.setup.ts @@ -0,0 +1,2 @@ +// vitest.setup.ts +import '@testing-library/jest-dom/vitest' \ No newline at end of file