fix(frontend): Selectieve testen in IDE

This commit is contained in:
Tibo De Peuter 2025-04-21 12:34:46 +02:00
parent 6017d9c54f
commit 196875538d
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
3 changed files with 10 additions and 6 deletions

View file

@ -12,8 +12,7 @@
"format": "prettier --write src/",
"format-check": "prettier --check src/",
"lint": "eslint . --fix",
"pretest:unit": "tsx ../docs/api/generate.ts && npm run build",
"test:unit": "VITE_API_BASE_URL='http://localhost:9876/api' vitest --run",
"test:unit": "vitest --run",
"test:e2e": "playwright test"
},
"dependencies": {

View file

@ -1,5 +1,10 @@
export const apiConfig = {
baseUrl: ((): string => {
if (import.meta.env.MODE === "test") {
// TODO Remove hardcoding
return "http://localhost:9876/api";
}
if (import.meta.env.VITE_API_BASE_URL) {
return import.meta.env.VITE_API_BASE_URL;
}

View file

@ -16,14 +16,14 @@ async function waitForEndpoint(url: string, delay = 1000, retries = 60): Promise
export async function setup(): Promise<void> {
// Precompile needed packages
spawnSync("npm", ["run", "predev"], {
cwd: "../backend",
spawnSync("npx", ["tsc", "--build", "tsconfig.json"], {
cwd: `../common`,
stdio: "inherit",
});
// Spin up the backend
backendProcess = spawn("tsx", ["--env-file=.env.test", "tool/startTestApp.ts"], {
cwd: "../backend",
backendProcess = spawn("npx", ["tsx", "--env-file=.env.test", "tool/startTestApp.ts"], {
cwd: `../backend`,
stdio: "inherit",
env: {
...process.env,