Skip to content

Commit

Permalink
chore: setup separated tsconfig for tests and build
Browse files Browse the repository at this point in the history
  • Loading branch information
markkovari committed Aug 16, 2024
1 parent 38fe353 commit 1b9a84c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 13 deletions.
9 changes: 5 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 4 additions & 9 deletions frontend/src/state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,11 @@ describe("state", () => {
state.result.current.auth.user = null;
});
expect(state.result.current.auth.token).toBeNull();
const exampleValidToken =
// biome-ignore lint
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" as const;
act(() => {
state.result.current.setToken("testTOKEN");
state.result.current.setAuth({
user: {
email: "email",
firstName: "firstName",
lastName: "lastName",
},
token: "testTOKEN",
});
state.result.current.setAuth(exampleValidToken);
});
expect(state.result.current.auth.token).not.toBeNull();
});
Expand Down
6 changes: 6 additions & 0 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@
"types": ["vitest/globals"]
},
"include": ["src", "src/tests/setup.ts"],
"exclude": [
"node_modules",
"src/tests/setup.ts",
"src/**/*.test.ts",
"src/**/*.test.tsx",
],
"references": [{ "path": "./tsconfig.node.json" }]
}
30 changes: 30 additions & 0 deletions frontend/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,

/* Needed for the Vitest */
"types": ["vitest/globals"]
},
"include": ["src", "src/tests/setup.ts", "src/tests/**/*.ts", "src/**/*.test.tsx"],

"references": [{ "path": "./tsconfig.node.json" }]
}
3 changes: 3 additions & 0 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export default defineConfig({
environment: "jsdom",
setupFiles: ["./setup-tests.ts"],
css: true,
typecheck: {
tsconfig: "./tsconfig.test.json",
},
coverage: {
exclude: [
"src/**/*.test.tsx",
Expand Down

0 comments on commit 1b9a84c

Please sign in to comment.