-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/add vitest testing library #173
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
Conversation
I installed Vitest, @vitest/ui, jsdom, @testing-library/react, and @testing-library/jest-dom. I configured Vitest to work with React and TypeScript: - Created `vitest.config.ts`. - Created `src/setupTests.ts` to import `@testing-library/jest-dom`. - Added `test` and `test:ui` scripts to `package.json`. I added initial tests for components: - A basic rendering test for the `Button` component. - Smoke tests for all other components in the `src` directory to ensure they render without crashing. Note: Due to persistent issues with the `pnpm` environment, I could not run the tests to confirm their passing status. I've created the setup and test files, but further verification in a stable environment will be required.
I've added a new GitHub Actions workflow (`.github/workflows/test.yml`) that triggers on push and pull requests to the main branch. The workflow performs the following steps: - Checks out the repository code. - Sets up Node.js v18. - Caches pnpm modules for faster builds. - Installs pnpm. - Installs project dependencies using pnpm. - Runs your test suite using `pnpm test`. This will help automate the testing process and ensure tests are run consistently.
Corrected the import statements in all component test files to use the actual exported component names (e.g., `NesButton`, `NesCheckbox`). Many components were being imported with generic names like `Button` while the actual exports were prefixed with `Nes`. Additionally, updated several smoke tests to include necessary props required for the components to render without errors, even for basic rendering checks. The `Dialog` component test was specifically corrected to reflect its actual implementation, which exports a `Dialog` component taking no props, after a previous erroneous correction attempt. These changes should resolve the "Element type is invalid" errors reported when running the tests.
✅ Deploy Preview for react-nes-components ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds Vitest as the testing framework, includes smoke tests for individual UI components, updates package.json with Vitest scripts/dependencies, and configures a GitHub Actions workflow to run tests on CI.
- Introduce a basic render smoke test for each component under
src/... - Add Vitest, Testing Library, and related devDependencies and scripts
- Add
.github/workflows/test.ymlto run tests on push/PR
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src//.test.tsx | Add smoke test for each component to verify render |
| package.json | Add vitest, @vitest/ui, testing-library deps and scripts |
| .github/workflows/test.yml | CI workflow to install deps and run Vitest tests |
Comments suppressed due to low confidence (1)
src/Textarea/Textarea.test.tsx:7
- This test currently only checks for a crash. Consider adding at least one assertion (e.g.,
expect(container.firstChild).toBeInTheDocument()or a snapshot test) to verify that the component renders expected markup.
render(<Textarea />);
| @@ -0,0 +1,9 @@ | |||
| import { render } from '@testing-library/react'; | |||
Copilot
AI
Jun 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Nearly identical smoke tests are duplicated across all component files. Consider using a parametrized test (e.g., describe.each) to loop through components and reduce boilerplate.
No description provided.