{"id":19388109,"url":"https://github.com/zakimohammed/react-vitest","last_synced_at":"2026-04-18T12:31:34.885Z","repository":{"id":228156053,"uuid":"773198617","full_name":"ZakiMohammed/react-vitest","owner":"ZakiMohammed","description":"Unit testing in React using Vitest","archived":false,"fork":false,"pushed_at":"2024-03-31T19:15:50.000Z","size":93,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-03T19:06:33.606Z","etag":null,"topics":["react","react-unit-testing","react-vitest","vitest"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZakiMohammed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-17T02:01:09.000Z","updated_at":"2024-03-17T09:30:58.000Z","dependencies_parsed_at":"2024-03-31T12:21:18.571Z","dependency_job_id":"626c1153-4d42-42c7-be1b-35710a184a1d","html_url":"https://github.com/ZakiMohammed/react-vitest","commit_stats":null,"previous_names":["zakimohammed/react-vitest"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ZakiMohammed/react-vitest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZakiMohammed%2Freact-vitest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZakiMohammed%2Freact-vitest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZakiMohammed%2Freact-vitest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZakiMohammed%2Freact-vitest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZakiMohammed","download_url":"https://codeload.github.com/ZakiMohammed/react-vitest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZakiMohammed%2Freact-vitest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31969508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react","react-unit-testing","react-vitest","vitest"],"created_at":"2024-11-10T10:11:48.507Z","updated_at":"2026-04-18T12:31:34.842Z","avatar_url":"https://github.com/ZakiMohammed.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Vitest\n\nUnit testing in React using Vitest.\n\n## Run App\n\nBelow command will run the project:\n\n```\nnpm run dev\n```\n\n## Test App\n\nBelow command will test the project:\n\n```\nnpm test\nnpm run test:ui\nnpm run test:watch\nnpm run test:coverage\n```\n\n## Initial Vitest Setup\n\nInstall Vitest in the application as dev dependency.\n\n```\nnpm i -D vitest\n```\n\nCreate `sum.js` file to test using `vitest`:\n\n```\nconst sum = (a, b) =\u003e a + b;\n\nexport default sum;\n```\n\nCreate `sum.test.js` file to write test cases for the same:\n\n```\nimport { expect, test } from 'vitest'\nimport sum from './Sum'\n\ntest('adds 1 + 2 to equal 3', () =\u003e {\n    expect(sum(1, 2)).toBe(3);\n});\n```\n\nInstall the `jsdom` package:\n\n```\nnpm i -D jsdom\n```\n\nAdd `jsdom` to `vite.config`:\n\n```\nimport { defineConfig } from 'vite'\nimport react from '@vitejs/plugin-react-swc'\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n  plugins: [react()],\n  test: {\n    environment: 'jsdom',       // 👈\n  }\n})\n```\n\nInstall React Testing Library:\n\n```\nnpm i -D @testing-library/jest-dom\nnpm i -D @testing-library/react\nnpm i -D @testing-library/user-event\n```\n\nCreate `App.test.js` file to write test cases for the App.jsx:\n\n```\nimport { expect, test } from 'vitest'\nimport App from './App'\nimport { render, screen } from '@testing-library/react'\n\ntest('renders', () =\u003e {\n    render(\u003cApp /\u003e)\n\n    expect(screen.getByText('Hello Vitest')).toBeInTheDocument()\n})\n```\n\nTesting Cases:\n\n- Test With Mock Data\n- Test With Mock Data Covering All Branches\n- Test User Interactions\n- Test State Updates\n- Test API Calls\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakimohammed%2Freact-vitest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzakimohammed%2Freact-vitest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakimohammed%2Freact-vitest/lists"}