flexprice/flexprice-front

Add Unit and Integration Tests for the Flexprice Frontend

开放

#180 创建于 2025年4月22日

 (3 条评论) (0 个反应) (1 位负责人)TypeScript (106 个派生)auto 404
documentationenhancementgood first issuehacktoberfesthelp wantedreactstorybook

仓库指标

星标
 (32 个星标)
PR 合并指标
 (平均合并 1天 1小时) (30 天内合并 116 个 PR)

描述

🧪 Write Unit & Integration Tests for Flexprice Frontend

We're looking for contributors to help us improve the test coverage of our frontend! 🚀
This is a great opportunity for first-time contributors to dive into open source with a real product.


📦 Tech Stack


🎯 Your Task

Help us write unit tests and integration tests for components, hooks, pages, and critical flows!

✅ Scope

  • Unit Tests:

    • Atomic components like Button, Input, Card in src/components/atoms/
    • Custom hooks in src/hooks/
  • Integration Tests:

    • Pages in src/pages/
    • Major flows like Billing, Dashboard, and Analytics in src/components/organisms/
  • Improve test structure and coverage using Vitest + Testing Library


🛠 Getting Started

Clone & Setup

git clone https://github.com/flexprice/flexprice-front
cd flexprice-front
npm install

Run the Dev Server

npm run dev

Run Tests

npm run test

💡 Note:
Create tests in the respective folders using the .test.tsx naming convention and follow the existing structure if available.


🧪 Example Test

Here’s a basic example for the Button component:

import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { Button } from './Button';

test('renders Button and handles click', async () => {
  const onClick = vi.fn();
  render(<Button onClick={onClick}>Click me</Button>);

  await userEvent.click(screen.getByText(/click me/i));
  expect(onClick).toHaveBeenCalledTimes(1);
});

✅ Acceptance Criteria

  • Add unit tests for at least 3 components (atoms, molecules, or organisms)
  • Add at least 1 integration test for a complete flow (e.g., form submission)
  • Use Vitest + @testing-library/react
  • Follow naming conventions: ComponentName.test.tsx
  • Ensure tests are self-contained, readable, and mimic real user behavior
  • Use data-testid only when necessary

💡 Tips


🔥 Good First Issues

If you're new to open source, start here:

  • src/components/atoms/Button/
  • src/hooks/useAuth.ts
  • src/pages/dashboard.tsx

🤝 How to Contribute

  1. Fork the repo

  2. Create a branch:

    git checkout -b test/<component-name>
    
  3. Add your test files

  4. Push and open a Pull Request with the title:
    ✅ Tests: <Component or Flow Name>


📚 Resources


📞 Need Help?

Leave a comment below or email us at support@flexprice.io — we're happy to guide you.


❤️ Thank You

Your contribution helps make Flexprice more stable and production-ready!
Happy testing! 🧪✨

贡献者指南