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

feat(tests): integrate Vitest and React Testing Library #2076

Merged
merged 3 commits into from
Jun 24, 2024
Merged

Conversation

hdinia
Copy link
Member

@hdinia hdinia commented Jun 21, 2024

Pull Request Description

Summary

This pull request enhances the CI pipeline by integrating Vitest for running unit tests and React Testing Library (RTL) with jsdom for DOM testing.

Changes Included

  • Installed Vitest for unit testing

    • Added Vitest as a development dependency.
    • Configured test scripts in package.json to use Vitest.
  • Installed React Testing Library and jsdom for DOM testing

    • Added React Testing Library and jsdom as development dependencies.
    • Included a basic test setup to ensure proper integration.
  • Configured test scripts in package.json

    • Added necessary scripts for building, linting, and testing the project.
  • Updated GitHub Actions workflow to include test steps

    • Modified the npm-test job to include steps for running Vitest tests.
    • Ensured the workflow checks out the repository, sets up Node.js, installs dependencies, and runs tests.

How to Test

  1. Local Testing

    • Run npm install to install the new dependencies.
    • Execute npm test to ensure Vitest and RTL run correctly and all tests pass.
  2. CI Testing

    • Push changes to a branch and verify that the GitHub Actions workflow runs successfully.
    • Confirm that the npm-test job completes without errors and that all tests pass.

image

Ressources:

Vitest
React Testing Library (RTL)
Jsdom

@hdinia hdinia changed the title Feature/add vitest ci(tests): integrate Vitest and React Testing Library into CI pipeline Jun 21, 2024
@hdinia hdinia self-assigned this Jun 21, 2024
@hdinia hdinia requested a review from skamril June 21, 2024 13:52
@hdinia hdinia changed the title ci(tests): integrate Vitest and React Testing Library into CI pipeline feat(tests): integrate Vitest and React Testing Library Jun 21, 2024
Copy link
Contributor

@laurent-laporte-pro laurent-laporte-pro left a comment

Choose a reason for hiding this comment

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

J'apprécie vraiment cette initiative d'ajouter des tests unitaires sur le frontend 🎉. C'est quelque chose qui, à mon avis, manquait à ce projet. Je vais aussi étudier attentivement les références documentaires que tu as fournies dans la description.

L'exécution de tests unitaires sur le frontend nécessite généralement de simuler les réponses des endpoints d'API. Il faut veiller à structurer ces mocks de manière logique (en général, on utilise l'arborescence dictée par les routes URL). Attention, cela peut vite devenir très chronophage !

webapp/package-lock.json Outdated Show resolved Hide resolved
webapp/vite.config.ts Show resolved Hide resolved
@hdinia
Copy link
Member Author

hdinia commented Jun 24, 2024

Added a simple test to allow the npm test check, because without tests it does not pass.

@hdinia hdinia force-pushed the feature/add-vitest branch from c96f574 to 1cfeb8b Compare June 24, 2024 07:47
@hdinia hdinia merged commit 5ec6e9d into dev Jun 24, 2024
7 checks passed
@hdinia hdinia deleted the feature/add-vitest branch June 24, 2024 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants