From 8cbb704ec19271a9372725eedc019a7a58b9894d Mon Sep 17 00:00:00 2001 From: Hans Christian Winther-Sorensen Date: Sun, 30 Jun 2024 22:21:19 +0200 Subject: [PATCH] Change location of test files to fix build issue --- .../+Page.test.tsx => test/pages/index.test.tsx} | 5 ++--- src/frontend/{src => }/test/setupTests.ts | 0 src/frontend/{src => }/test/testUtils.tsx | 0 src/frontend/tsconfig.json | 10 ++++++---- src/frontend/vite.config.ts | 6 ++++-- 5 files changed, 12 insertions(+), 9 deletions(-) rename src/frontend/{src/pages/index/__tests__/+Page.test.tsx => test/pages/index.test.tsx} (70%) rename src/frontend/{src => }/test/setupTests.ts (100%) rename src/frontend/{src => }/test/testUtils.tsx (100%) diff --git a/src/frontend/src/pages/index/__tests__/+Page.test.tsx b/src/frontend/test/pages/index.test.tsx similarity index 70% rename from src/frontend/src/pages/index/__tests__/+Page.test.tsx rename to src/frontend/test/pages/index.test.tsx index 6d32ec72..c2b3e770 100644 --- a/src/frontend/src/pages/index/__tests__/+Page.test.tsx +++ b/src/frontend/test/pages/index.test.tsx @@ -1,8 +1,7 @@ +import { render, screen } from '~test/testUtils' import { expect, it } from 'vitest' -import { render, screen } from '~/test/testUtils' - -import Page from '../+Page' +import Page from '~/pages/index/+Page' it('renders welcome message', () => { render(, { mockAuthContext: true, withQueryProvider: true }) diff --git a/src/frontend/src/test/setupTests.ts b/src/frontend/test/setupTests.ts similarity index 100% rename from src/frontend/src/test/setupTests.ts rename to src/frontend/test/setupTests.ts diff --git a/src/frontend/src/test/testUtils.tsx b/src/frontend/test/testUtils.tsx similarity index 100% rename from src/frontend/src/test/testUtils.tsx rename to src/frontend/test/testUtils.tsx diff --git a/src/frontend/tsconfig.json b/src/frontend/tsconfig.json index 31ea0423..c240fdfc 100644 --- a/src/frontend/tsconfig.json +++ b/src/frontend/tsconfig.json @@ -7,10 +7,12 @@ "skipLibCheck": true, /* Paths */ - "baseUrl": "src", + "baseUrl": ".", "paths": { - "~/*": ["*"], - "~components/*": ["components/*"] + "~/*": ["src/*"], + //"~components/*": ["src/components/*"], + //"~pages/*": ["src/pages/*"], + "~test/*": ["test/*"] }, /* Bundler mode */ @@ -30,6 +32,6 @@ "strictNullChecks": true, "allowJs": true }, - "include": ["src", "eslint.config.mjs", "orval.config.cjs"], + "include": ["src", "test", "eslint.config.mjs", "orval.config.cjs"], "references": [{ "path": "./tsconfig.node.json" }] } diff --git a/src/frontend/vite.config.ts b/src/frontend/vite.config.ts index 3047a8e5..195ecf10 100644 --- a/src/frontend/vite.config.ts +++ b/src/frontend/vite.config.ts @@ -12,7 +12,9 @@ export default defineConfig({ resolve: { alias: { '~': '/src', - '~components': '/src/components', + //'~components': '/src/components', + //'~pages': '/src/pages', + '~test': '/test', }, }, build: { @@ -22,7 +24,7 @@ export default defineConfig({ test: { globals: true, environment: 'jsdom', - setupFiles: './src/test/setupTests.ts', + setupFiles: './test/setupTests.ts', mockReset: true, coverage: { enabled: true, provider: 'istanbul', reporter: ['cobertura', 'lcov', 'html'] }, reporters: ['verbose', 'github-actions', 'junit'],