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

Changed the OrgContribution from jest to vitest #2635

Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand All @@ -18,6 +26,21 @@ async function wait(ms = 100): Promise<void> {
});
});
}
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 () => {
Expand Down
4 changes: 2 additions & 2 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

The setup file path in vitest.config.ts needs to be updated

The specified path src/test/setup.ts does not exist. Instead, there is a vitest.setup.ts file in the root directory that contains the necessary test configurations including @testing-library/jest-dom. The path in vitest.config.ts should be updated to point to this existing file.

  • Update setupFiles: ['src/test/setup.ts'] to setupFiles: ['vitest.setup.ts'] in vitest.config.ts
🔗 Analysis chain

Verify setup file existence and configuration

The setupFiles path has been updated to use src/test/setup.ts. Let's verify this file exists and contains necessary test configurations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the setup file exists and contains required configurations
if [ -f "src/test/setup.ts" ]; then
    echo "Setup file exists"
    # Check for common testing library imports
    rg -n "import.*testing-library" "src/test/setup.ts"
    # Check for jest-dom setup
    rg -n "jest-dom" "src/test/setup.ts"
else
    echo "Setup file missing at src/test/setup.ts"
fi

Length of output: 119


Script:

#!/bin/bash
# Let's check if the setup file exists in any other location
fd -e ts "setup.ts"

# Also check the git history for any recent changes to setup files
git log --oneline -n 5 | grep -i "setup"

# Let's also check the package.json for any test-related configurations
cat package.json | jq '.scripts | select(has("test"))'

Length of output: 1247


Script:

#!/bin/bash
# Let's check the content of both setup files we found
echo "=== Content of setup.ts ==="
cat setup.ts

echo -e "\n=== Content of vitest.setup.ts ==="
cat vitest.setup.ts

# Also check if there are any references to these setup files in the codebase
echo -e "\n=== References to setup files ==="
rg -l "setup.ts"

Length of output: 6371

coverage: {
enabled: true,
provider: 'istanbul',
Expand Down
Loading