Skip to content

Commit

Permalink
test: 기존 테스트 실패 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
llqqssttyy committed Sep 10, 2024
1 parent 087275d commit 85e0393
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
'^@types/(.*)$': '<rootDir>/src/types/$1',
'^@utils/(.*)$': '<rootDir>/src/utils/$1',
'^@mocks/(.*)$': '<rootDir>/src/mocks/$1',
'^@router/(.*)$': '<rootDir>/src/router/$1',
},
testEnvironmentOptions: {
customExportConditions: [''],
Expand Down
6 changes: 6 additions & 0 deletions frontend/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ global.React = React;

beforeAll(() => {
server.listen({ onUnhandledRequest: 'error' });

jest.spyOn(Storage.prototype, 'setItem');
jest.spyOn(Storage.prototype, 'getItem');
jest.spyOn(Storage.prototype, 'removeItem');
});

afterEach(() => {
server.resetHandlers();

jest.restoreAllMocks();
});

afterAll(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import { PropsWithChildren } from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { act, renderHook } from '@testing-library/react';
import ToastProvider from '@contexts/ToastContext';
import useDashboardCreateForm from '.';

describe('useDashboardCreateForm', () => {
beforeAll(() => {
localStorage.setItem('clubId', '1');
});

afterAll(() => {
localStorage.removeItem('clubId');
});

const createWrapper = () => {
const queryClient = new QueryClient();
// eslint-disable-next-line react/function-component-definition
return ({ children }: PropsWithChildren) => (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
<ToastProvider>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</ToastProvider>
);
};

Expand Down

0 comments on commit 85e0393

Please sign in to comment.