Skip to content

Commit feb07e8

Browse files
committed
Update dev dependencies fix the jest setups
1 parent 9b25493 commit feb07e8

File tree

5 files changed

+32
-93
lines changed

5 files changed

+32
-93
lines changed

frontend/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"@microsoft/fetch-event-source": "2.0.1",
1111
"@szhsin/react-menu": "3.5.3",
1212
"@tanstack/react-query": "4.36.1",
13+
"@tanstack/react-query-devtools": "4.36.1",
1314
"@tanstack/react-table": "8.16.0",
1415
"ace-builds": "1.33.0",
1516
"ajv": "8.8.2",
@@ -32,8 +33,7 @@
3233
"styled-components": "6.1.8",
3334
"use-debounce": "10.0.0",
3435
"yup": "1.4.0",
35-
"zustand": "4.5.2",
36-
"@tanstack/react-query-devtools": "4.36.1"
36+
"zustand": "4.5.2"
3737
},
3838
"scripts": {
3939
"start": "vite",
@@ -58,8 +58,8 @@
5858
"@swc/jest": "0.2.36",
5959
"@testing-library/dom": "10.0.0",
6060
"@testing-library/jest-dom": "6.4.2",
61-
"@testing-library/user-event": "14.5.2",
6261
"@testing-library/react": "14.3.1",
62+
"@testing-library/user-event": "14.5.2",
6363
"@types/eventsource": "1.1.15",
6464
"@types/lossless-json": "1.0.4",
6565
"@types/node": "20.11.17",
@@ -68,12 +68,9 @@
6868
"@types/react-dom": "18.2.25",
6969
"@types/react-router-dom": "5.3.3",
7070
"@types/styled-components": "5.1.34",
71+
"@types/testing-library__jest-dom": "5.14.9",
7172
"@typescript-eslint/eslint-plugin": "6.21.0",
7273
"@typescript-eslint/parser": "6.21.0",
73-
"vite": "5.2.10",
74-
"vite-tsconfig-paths": "4.3.2",
75-
"vite-plugin-checker": "0.6.4",
76-
"vite-plugin-ejs": "1.7.0",
7774
"@vitejs/plugin-react-swc": "3.6.0",
7875
"dotenv": "16.4.5",
7976
"eslint": "8.57.0",
@@ -88,18 +85,21 @@
8885
"eslint-plugin-prettier": "5.1.3",
8986
"eslint-plugin-react": "7.34.1",
9087
"eslint-plugin-react-hooks": "4.6.0",
91-
"@types/testing-library__jest-dom": "5.14.9",
88+
"fetch-mock": "9.11.0",
9289
"jest": "29.7.0",
93-
"jest-watch-typeahead": "2.2.2",
9490
"jest-environment-jsdom": "29.7.0",
9591
"jest-sonar-reporter": "2.0.0",
9692
"jest-styled-components": "7.1.1",
93+
"jest-watch-typeahead": "2.2.2",
9794
"prettier": "3.2.5",
9895
"rimraf": "5.0.5",
9996
"ts-node": "10.9.2",
10097
"ts-prune": "0.10.3",
10198
"typescript": "5.4.5",
102-
"fetch-mock": "9.11.0",
99+
"vite": "5.2.10",
100+
"vite-plugin-checker": "0.6.4",
101+
"vite-plugin-ejs": "1.7.0",
102+
"vite-tsconfig-paths": "4.3.2",
103103
"whatwg-fetch": "3.6.20"
104104
},
105105
"engines": {

frontend/pnpm-lock.yaml

Lines changed: 7 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/lib/testHelpers.tsx

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import React, { PropsWithChildren, ReactElement, useMemo } from 'react';
1+
import React, {
2+
FC,
3+
ReactNode,
4+
PropsWithChildren,
5+
ReactElement,
6+
useMemo,
7+
} from 'react';
28
import {
39
MemoryRouter,
410
MemoryRouterProps,
@@ -38,7 +44,7 @@ interface CustomRenderOptions extends Omit<RenderOptions, 'wrapper'> {
3844
}
3945

4046
interface WithRouteProps {
41-
children: React.ReactNode;
47+
children: ReactNode;
4248
path: string;
4349
}
4450

@@ -51,15 +57,15 @@ export const expectQueryWorks = async (
5157
expect(result.current.data).toBeDefined();
5258
};
5359

54-
export const WithRoute: React.FC<WithRouteProps> = ({ children, path }) => {
60+
export const WithRoute: FC<WithRouteProps> = ({ children, path }) => {
5561
return (
5662
<Routes>
5763
<Route path={path} element={children} />
5864
</Routes>
5965
);
6066
};
6167

62-
export const TestQueryClientProvider: React.FC<PropsWithChildren<unknown>> = ({
68+
export const TestQueryClientProvider: FC<PropsWithChildren<unknown>> = ({
6369
children,
6470
}) => {
6571
// use new QueryClient instance for each test run to avoid issues with cache
@@ -75,7 +81,7 @@ export const TestQueryClientProvider: React.FC<PropsWithChildren<unknown>> = ({
7581
* @description it will create a UserInfo Provider that will actually
7682
* disable the rbacFlag , to user if you can pass it as an argument
7783
* */
78-
const TestUserInfoProvider: React.FC<
84+
const TestUserInfoProvider: FC<
7985
PropsWithChildren<{ data?: { roles?: RolesType; rbacFlag: boolean } }>
8086
> = ({ children, data }) => {
8187
const contextValue = useMemo(() => {
@@ -107,9 +113,7 @@ const customRender = (
107113
}: CustomRenderOptions = {}
108114
) => {
109115
// overrides @testing-library/react render.
110-
const AllTheProviders: React.FC<PropsWithChildren<unknown>> = ({
111-
children,
112-
}) => (
116+
const AllTheProviders: FC<PropsWithChildren<unknown>> = ({ children }) => (
113117
<TestQueryClientProvider>
114118
<GlobalSettingsContext.Provider
115119
value={globalSettings || { hasDynamicConfig: false }}
@@ -136,23 +140,3 @@ const customRenderHook = (hook: () => UseQueryResult<unknown, unknown>) =>
136140
renderHook(hook, { wrapper: TestQueryClientProvider });
137141

138142
export { customRender as render, customRenderHook as renderQueryHook };
139-
140-
export class EventSourceMock {
141-
url: string;
142-
143-
close: () => void;
144-
145-
open: () => void;
146-
147-
error: () => void;
148-
149-
onmessage: () => void;
150-
151-
constructor(url: string) {
152-
this.url = url;
153-
this.open = jest.fn();
154-
this.error = jest.fn();
155-
this.onmessage = jest.fn();
156-
this.close = jest.fn();
157-
}
158-
}

frontend/src/setupTests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import 'whatwg-fetch';
22
import 'jest-styled-components';
3-
import '@testing-library/jest-dom';
3+
import '@testing-library/jest-dom/jest-globals';

frontend/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
"jsx": "react-jsx",
2121
"baseUrl": "src",
2222
"noFallthroughCasesInSwitch": true,
23-
"types": ["vite/client"]
23+
"types": ["vite/client","@testing-library/jest-dom"]
2424
},
2525
"include": [
2626
"src",
2727
"vite.config.ts",
2828
"jest.config.ts",
29+
"src/setupTests.ts"
2930
]
3031
}

0 commit comments

Comments
 (0)