Skip to content

Commit

Permalink
changed the way to access global var so that vitest does not throw an…
Browse files Browse the repository at this point in the history
… error not defined
  • Loading branch information
benoitquette committed Mar 17, 2024
1 parent 764977a commit fcc67af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/config.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default {
export const drawerWidth = 260;

export const urlApiProjects = import.meta.env.VITE_URL_API_PROJECTS ?? globalThis['apiProjectsUrl'];
export const urlApiUsers = import.meta.env.VITE_URL_API_USERS ?? apiUsersUrl;
export const urlApiReports = import.meta.env.VITE_URL_API_REPORTS ?? apiReportsUrl;
export const urlApiUsers = import.meta.env.VITE_URL_API_USERS ?? globalThis['apiUsersUrl'];
export const urlApiReports = import.meta.env.VITE_URL_API_REPORTS ?? globalThis['apiReportsUrl'];

export const severities = [
{ from: 0, color: red, name: 'bad' },
Expand Down
11 changes: 2 additions & 9 deletions vitest-setup.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import '@testing-library/jest-dom/vitest';
import { beforeAll, vi } from 'vitest';
import { beforeAll } from 'vitest';

beforeAll(() => {
window.apiProjectsUrl = 'fake';
globalThis.apiProjectsUrl = 'fake';
vi.stubGlobal('apiProjectsUrl', 'fake');
global.apiProjectsUrl = 'fake';
// console.log('apiProjectsUrl: ' + apiProjectsUrl);
// console.log('urlApiProjects: ' + config.urlApiProjects);
});
beforeAll(() => {});

0 comments on commit fcc67af

Please sign in to comment.