Skip to content

Commit

Permalink
Refactored src/components/GroupChatDetails from jest to vitest (#3453)
Browse files Browse the repository at this point in the history
* Refactored src/components/GroupChatDetails from jest to vitest

* removed all instances and files related to jest

* removed all instances and files related to jest

* cleanup to eradicate jest fully

* chore!: port to exclude instead ignore

* refactor! path

---------

Co-authored-by: Vamshi Maskuri <[email protected]>
  • Loading branch information
syedali237 and varshith257 authored Jan 27, 2025
1 parent 73cf8cd commit 0445cb8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 145 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"extends": [
"plugin:react/recommended",
"eslint:recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended",
"eslint-config-prettier",
Expand All @@ -30,7 +29,6 @@
"plugins": [
"react",
"@typescript-eslint",
"jest",
"import",
"eslint-plugin-tsdoc",
"prettier"
Expand Down Expand Up @@ -128,8 +126,6 @@
"react/jsx-equals-spacing": ["warn", "never"],
"react/no-this-in-sfc": "error",

"jest/expect-expect": 0,

"react/no-unstable-nested-components": ["error", { "allowAsProps": true }],
"react/function-component-definition": [
0,
Expand Down
39 changes: 4 additions & 35 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,51 +243,20 @@ jobs:
- name: Get changed TypeScript files
id: changed-files
uses: tj-actions/changed-files@v45

- name: Run Jest Tests
if: steps.changed-files.outputs.any_changed == 'true'
env:
NODE_V8_COVERAGE: './coverage/jest'
run: |
npm run test -- --watchAll=false --coverage
- name: Upload Jest Coverage to Codecov
if: steps.changed-files.outputs.any_changed == 'true'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/jest/lcov.info
flags: jest
fail_ci_if_error: true

- name: Run Vitest Tests
if: steps.changed-files.outputs.any_changed == 'true'
env:
NODE_V8_COVERAGE: './coverage/vitest'
run: |
npm run test:vitest:coverage
- name: Upload Vitest Coverage to Codecov
if: steps.changed-files.outputs.any_changed == 'true'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/vitest/lcov.info
flags: vitest
fail_ci_if_error: true

- name: Merge Jest and Vitest Coverage Reports
run: |
mkdir -p ./coverage
npx lcov-result-merger './coverage/*/lcov.info' './coverage/lcov.info'
- name: Upload Combined Coverage to Codecov
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
gcov_ignore: 'docs/'
files: ./coverage/lcov.info
flags: combined
exclude: 'docs/'
files: ./coverage/vitest/lcov.info
fail_ci_if_error: true

- name: TypeScript compilation for changed files
Expand All @@ -301,7 +270,7 @@ jobs:
- name: Test acceptable level of code coverage
uses: VeryGoodOpenSource/very_good_coverage@v3
with:
path: "./coverage/lcov.info"
path: "./coverage/vitest/lcov.info"
min_coverage: 0

# Graphql-Inspector:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/countline.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _valid_filename(filepath):
"""
# Initialize key variables
invalid_filenames = [".test.", ".spec."]
invalid_filenames = [".spec."]
result = True

# Test
Expand Down
5 changes: 0 additions & 5 deletions jest-preview.config.ts

This file was deleted.

86 changes: 0 additions & 86 deletions jest.config.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React from 'react';
import {
render,
screen,
// fireEvent,
// waitFor,
act,
fireEvent,
waitFor,
Expand All @@ -18,6 +16,7 @@ import { USERS_CONNECTION_LIST } from 'GraphQl/Queries/Queries';
import { I18nextProvider, initReactI18next } from 'react-i18next';
import i18n from 'i18next';
import { useLocalStorage } from 'utils/useLocalstorage';
import { vi } from 'vitest';

const { setItem } = useLocalStorage();

Expand Down Expand Up @@ -432,10 +431,10 @@ describe('GroupChatDetails', () => {
<I18nextProvider i18n={i18n}>
<MockedProvider mocks={mocks} addTypename={false}>
<GroupChatDetails
toggleGroupChatDetailsModal={jest.fn()}
toggleGroupChatDetailsModal={vi.fn()}
groupChatDetailsModalisOpen={true}
chat={chat}
chatRefetch={jest.fn()}
chatRefetch={vi.fn()}
/>
</MockedProvider>
</I18nextProvider>,
Expand All @@ -456,10 +455,10 @@ describe('GroupChatDetails', () => {
<I18nextProvider i18n={i18n}>
<MockedProvider mocks={mocks} addTypename={false}>
<GroupChatDetails
toggleGroupChatDetailsModal={jest.fn()}
toggleGroupChatDetailsModal={vi.fn()}
groupChatDetailsModalisOpen={true}
chat={mockChat}
chatRefetch={jest.fn()}
chatRefetch={vi.fn()}
/>
</MockedProvider>
</I18nextProvider>,
Expand Down Expand Up @@ -518,10 +517,10 @@ describe('GroupChatDetails', () => {
<I18nextProvider i18n={i18n}>
<MockedProvider mocks={mocks} addTypename={false}>
<GroupChatDetails
toggleGroupChatDetailsModal={jest.fn()}
toggleGroupChatDetailsModal={vi.fn()}
groupChatDetailsModalisOpen={true}
chat={mockChat}
chatRefetch={jest.fn()}
chatRefetch={vi.fn()}
/>
</MockedProvider>
</I18nextProvider>,
Expand Down Expand Up @@ -558,19 +557,17 @@ describe('GroupChatDetails', () => {
await act(async () => {
fireEvent.click(await screen.findByTestId('addUserBtn'));
});

await wait(10000);
});
// test case for updating group chat image
it('update group chat image', async () => {
render(
<I18nextProvider i18n={i18n}>
<MockedProvider mocks={mocks} addTypename={false}>
<GroupChatDetails
toggleGroupChatDetailsModal={jest.fn()}
toggleGroupChatDetailsModal={vi.fn()}
groupChatDetailsModalisOpen={true}
chat={mockChat}
chatRefetch={jest.fn()}
chatRefetch={vi.fn()}
/>
</MockedProvider>
</I18nextProvider>,
Expand All @@ -597,7 +594,5 @@ describe('GroupChatDetails', () => {
});

fireEvent.change(fileInput);

await wait(10000);
});
});

0 comments on commit 0445cb8

Please sign in to comment.