Skip to content

Conversation

@koji
Copy link
Owner

@koji koji commented Jun 5, 2025

No description provided.

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.
@netlify
Copy link

netlify bot commented Jun 5, 2025

Deploy Preview for react-nes-components ready!

Name Link
🔨 Latest commit dbd0bc4
🔍 Latest deploy log https://app.netlify.com/projects/react-nes-components/deploys/6841541aefb2ad00084a2c42
😎 Deploy Preview https://deploy-preview-173--react-nes-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@koji koji requested a review from Copilot June 6, 2025 06:56
Copy link

Copilot AI left a 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.yml to 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';
Copy link

Copilot AI Jun 6, 2025

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.

Copilot uses AI. Check for mistakes.
@koji koji merged commit 56fceb9 into develop Jun 6, 2025
6 checks passed
@koji koji deleted the feat/add-vitest-testing-library branch June 6, 2025 06:58
@koji koji mentioned this pull request Jun 6, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants