From 90c5ad8d57ab28c9ce584259fd67e80681ffc497 Mon Sep 17 00:00:00 2001 From: Akshat Date: Wed, 11 Dec 2024 14:37:15 +0530 Subject: [PATCH] Changed the OrgContribution from jest to vitest --- ...tion.test.tsx => OrgContribution.spec.tsx} | 23 +++++++++++++++++++ vitest.config.ts | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) rename src/screens/OrgContribution/{OrgContribution.test.tsx => OrgContribution.spec.tsx} (74%) diff --git a/src/screens/OrgContribution/OrgContribution.test.tsx b/src/screens/OrgContribution/OrgContribution.spec.tsx similarity index 74% rename from src/screens/OrgContribution/OrgContribution.test.tsx rename to src/screens/OrgContribution/OrgContribution.spec.tsx index f9f63c6807..95e0e9563a 100644 --- a/src/screens/OrgContribution/OrgContribution.test.tsx +++ b/src/screens/OrgContribution/OrgContribution.spec.tsx @@ -1,3 +1,9 @@ +/** + * Unit tests for the AddOn component. + * + * This file contains tests for the OrgContribution to ensure it behaves as expected + * under various scenarios. + */ import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; import { render } from '@testing-library/react'; @@ -7,6 +13,8 @@ import 'jest-location-mock'; import { I18nextProvider } from 'react-i18next'; import OrgContribution from './OrgContribution'; +import '@testing-library/jest-dom'; +import { describe, test, expect, vi } from 'vitest'; import { store } from 'state/store'; import i18nForTest from 'utils/i18nForTest'; import { StaticMockLink } from 'utils/StaticMockLink'; @@ -18,6 +26,21 @@ async function wait(ms = 100): Promise { }); }); } +vi.mock('state/store', () => ({ + store: { + // Mock store configuration if needed + getState: vi.fn(), + subscribe: vi.fn(), + dispatch: vi.fn(), + }, +})); + +vi.mock('utils/i18nForTest', () => ({ + __esModule: true, + default: vi.fn(() => ({ + t: (key: string) => key, + })), +})); describe('Organisation Contribution Page', () => { test('should render props and text elements test for the screen', async () => { diff --git a/vitest.config.ts b/vitest.config.ts index ad85276111..8fec9067dd 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -12,10 +12,10 @@ export default defineConfig({ tsconfigPaths(), ], test: { - include: ['src/**/*.spec.{js,jsx,ts,tsx}'], + include: ['src/**/*.{spec,test}.{js,jsx,ts,tsx}'], globals: true, environment: 'jsdom', - setupFiles: 'vitest.setup.ts', + setupFiles: ['src/test/setup.ts'], coverage: { enabled: true, provider: 'istanbul',