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/AddOn/support/components/Action/Action.test.tsx from Jest to Vitest #2482

Merged
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
31 changes: 31 additions & 0 deletions src/components/AddOn/support/components/Action/Action.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Unit tests for the Action component.
*
* This file contains tests for the Action component to ensure it behaves as expected
* under various scenarios.
*/
import React from 'react';
import { render } from '@testing-library/react';
import { Provider } from 'react-redux';
import { describe, test, expect } from 'vitest';

import { store } from 'state/store';
import Action from './Action';

describe('Testing Action Component', () => {
const props = {
children: 'dummy children',
label: 'dummy label',
};

test('should render props and text elements for the page component', () => {
const { getByText } = render(
<Provider store={store}>
<Action {...props} />
</Provider>,
);

expect(getByText(props.label)).toBeInTheDocument();
expect(getByText(props.children)).toBeInTheDocument();
});
});
3 changes: 2 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from 'vite';
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import tsconfigPaths from 'vite-tsconfig-paths';
Expand All @@ -15,6 +15,7 @@ export default defineConfig({
include: ['src/**/*.spec.{js,jsx,ts,tsx}'],
globals: true,
environment: 'jsdom',
setupFiles: 'vitest.setup.ts',
varshith257 marked this conversation as resolved.
Show resolved Hide resolved
coverage: {
enabled: true,
provider: 'istanbul',
Expand Down
1 change: 1 addition & 0 deletions vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom';
Loading