Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored src/components/GroupChatDetails from jest to vitest #3453

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{

Check warning on line 1 in .eslintrc.json

View workflow job for this annotation

GitHub Actions / Performs linting, formatting, type-checking, checking for different source and target branch

File ignored by default.
"env": {
"browser": true,
"node": true,
Expand All @@ -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
35 changes: 2 additions & 33 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##############################################################################

Check warning on line 1 in .github/workflows/pull-request.yml

View workflow job for this annotation

GitHub Actions / Performs linting, formatting, type-checking, checking for different source and target branch

File ignored by default.
##############################################################################
#
# NOTE!
Expand Down Expand Up @@ -243,51 +243,20 @@
- 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
files: ./coverage/vitest/lcov.info
varshith257 marked this conversation as resolved.
Show resolved Hide resolved
fail_ci_if_error: true

- name: TypeScript compilation for changed files
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/countline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3

Check warning on line 1 in .github/workflows/scripts/countline.py

View workflow job for this annotation

GitHub Actions / Performs linting, formatting, type-checking, checking for different source and target branch

File ignored by default.
# -*- coding: UTF-8 -*-
"""Script to encourage more efficient coding practices.

Expand Down Expand Up @@ -41,7 +41,7 @@

"""
# 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);
});
});
Loading