Skip to content

Andersonlimahw/boilerplate-reactjs-tests

Repository files navigation

Welcome to amazing react boilerplate πŸ‘‹

Version License: MIT Twitter: anderson.lima.dev

Boilerplate : PWA project using vite, react, zustand, tailwindcss, vitest, playwright and more!

✨ Demo

Look a project using this boilerplate

Using

Use has template

using-template

Or fork: using-template

Customize pages how you need!

✨ Features ✨:

  • Created using vite a very fast front-end tooling

  • Toasts with react-tostify

  • zustand for global state management

  • React query for request state management

  • Base service to manage your requests

  • Mocks with miragejs

  • Vitest for unit tests and code coverage collect

  • Playwright for E2E testing with multi-browser support

  • Comprehensive testing suite (unit, component, and E2E tests)

  • PWA support with offline capabilities

  • TypeScript support for type safety

  • Tailwind CSS for styling

  • Comprehensive documentation in /src/docs

Boilerplates

Boilerplates are pre-made templates or frameworks that contain a foundational structure, configurations, and often basic functionalities for a particular type of project. They're designed to help kick-start development by providing a starting point, allowing developers to avoid repetitive setup tasks and focus on building specific features.

You can get more boilerplates in this github profile: click here for more boilerplates πŸ‘©πŸΎβ€πŸŽ€

Install

npm install

Run

npm run dev

Open link in your favorite your browser: http://localhost:5173

Testing

Unit Tests

Run unit tests with Vitest:

npm run test

Run tests with coverage:

npm run test:coverage

E2E Tests

Run E2E tests with Playwright:

# Run all E2E tests
npm run test:e2e

# Run E2E tests with UI mode
npm run test:e2e:ui

# Run E2E tests in headed mode (see browser)
npm run test:e2e:headed

# Run E2E tests in debug mode
npm run test:e2e:debug

# Run tests on specific browsers
npm run test:e2e:chromium
npm run test:e2e:firefox
npm run test:e2e:webkit

# Run tests on mobile viewports
npm run test:e2e:mobile

# View test report
npm run test:e2e:report

Install Playwright browsers

npm run playwright:install

Test Coverage

The project includes comprehensive test coverage including:

  • Unit tests for components and utilities
  • Component tests with React Testing Library
  • E2E tests covering critical user flows:
    • Login and authentication
    • Chat functionality
    • Profile management
    • Settings page
    • Navigation flows
    • API feedback states
    • Community features
    • Groups management

For more details, see the Testing Documentation and E2E Documentation

Technologies and strategies:

Core Technologies

vite - Fast front-end tooling
react - UI library
typescript - Type safety
pwa - Progressive Web App support

State Management & Data Fetching

zustand - Global state management
react-query - Server state management

Styling

tailwindcss - Utility-first CSS framework

Testing

vitest - Unit testing framework
playwright - E2E testing framework
@testing-library/react - React component testing
miragejs - API mocking

Additional Tools

firebase - Backend services
radix-ui - Accessible UI components

Documentation

Comprehensive documentation is available in the /src/docs directory:

Project Structure

boilerplate-reactjs-testes/
β”œβ”€β”€ e2e/                        # E2E tests with Playwright
β”‚   └── tests/                  # E2E test files
β”‚       β”œβ”€β”€ login.spec.ts
β”‚       β”œβ”€β”€ chat.spec.ts
β”‚       β”œβ”€β”€ profile.spec.ts
β”‚       β”œβ”€β”€ settings.spec.ts
β”‚       β”œβ”€β”€ navigation.spec.ts
β”‚       β”œβ”€β”€ community.spec.ts
β”‚       β”œβ”€β”€ groups.spec.ts
β”‚       └── api-feedback.spec.ts
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ commons/                # Shared components and utilities
β”‚   β”‚   └── components/         # Reusable components
β”‚   β”œβ”€β”€ pages/                  # Page components
β”‚   β”‚   β”œβ”€β”€ Chat/
β”‚   β”‚   β”œβ”€β”€ Community/
β”‚   β”‚   β”œβ”€β”€ Groups/
β”‚   β”‚   β”œβ”€β”€ Profile/
β”‚   β”‚   └── Settings/
β”‚   β”œβ”€β”€ docs/                   # Project documentation
β”‚   └── mocks/                  # API mocks with MirageJS
β”œβ”€β”€ playwright.config.ts        # Playwright configuration
β”œβ”€β”€ vite.config.js              # Vite and Vitest configuration
└── vitest.setup.ts             # Vitest setup file

Browser Support

The E2E tests are configured to run on:

  • Desktop: Chrome, Firefox, Safari (WebKit)
  • Mobile: Chrome (Pixel 5), Safari (iPhone 12)

CI/CD Ready

The testing setup is optimized for CI/CD environments:

  • Configurable retry logic for flaky tests
  • HTML and JSON reporters for test results
  • Screenshots and videos on test failure
  • Parallel test execution support
  • Coverage reporting

Author

πŸ‘€ Anderson Lima (Lemon πŸ‹)

⭐ Show your support

give a ⭐ if this project helped you!

About

Reactjs boilerplate with testes e2e

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published