Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.staging
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_API_URL=
VITE_API_URL=http://localhost:5173/api
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview",
"remove-build": "rm -rf -d ./dist ./dist-staging",
"test:unit": "TZ=Africa vitest",
"test:unit:coverage": "TZ=Africa vitest run --coverage",
"test:unit:ci": "TZ=Africa vitest run",
"test:unit": "TZ=Africa vitest --mode staging",
"test:unit:coverage": "TZ=Africa vitest run --coverage --mode staging",
"test:unit:ci": "TZ=Africa vitest run --mode staging",
"test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e'",
"test:e2e:dev": "start-server-and-test 'vite dev --port 4173' http://localhost:4173 'cypress open --e2e'",
"build-only": "vite build",
Expand Down
4 changes: 1 addition & 3 deletions src/utils/__tests__/apiConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { OpenAPI } from "@/services/apis/user";

describe("apiConfig", () => {
it("should set the config", () => {
const apiUrl = "http://localhost:5173/api";
process.env.VITE_API_URL = apiUrl;
setApiBaseUrl();
expect(OpenAPI.BASE).toBe(apiUrl);
expect(OpenAPI.BASE).toBe(import.meta.env.VITE_API_URL);
});
});
2 changes: 2 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { fileURLToPath } from "node:url";
import { configDefaults, defineConfig, mergeConfig } from "vitest/config";
import viteConfig from "./vite.config";
import { loadEnv } from "vite";

export default defineConfig((configEnv) =>
mergeConfig(
Expand Down Expand Up @@ -43,6 +44,7 @@ export default defineConfig((configEnv) =>
"**/*.spec.ts",
],
},
env: loadEnv(configEnv.mode, process.cwd(), ""), // mode defines what ".env.{mode}" file to choose if exists
},
}),
),
Expand Down