Skip to content

Conversation

@Pranav92005
Copy link
Contributor

Summary

This PR introduces a complete unit testing setup using Vitest for the Sugar Labs React website.
While implementing the testing infrastructure, it also fixes existing issues that were preventing tests from running successfully.

Changes Made

  • Added Vitest, jsdom, @testing-library/react, and @testing-library/jest-dom as dev dependencies
  • Configured Vitest for a React + jsdom environment
  • Added global test setup file (src/setupTests.ts)
  • Added test scripts to package.json:
    • test (watch mode)
    • test:run (CI mode)
    • coverage
  • Added a basic App render test to verify the setup
  • Fixed invalid import.meta.glob usage by replacing alias paths (@/) with Vite-compatible absolute /src/... paths in:
    • posts-utils.ts
    • author-utils.ts

Why this change

The CONTRIBUTING.md file explicitly mentions that unit tests should be part of PRs, but the project did not have any testing framework configured.

While setting up Vitest, a Vite limitation surfaced where import.meta.glob does not support path aliases. These paths were updated to ensure compatibility across development, testing, and CI environments.

Notes

This PR focuses only on establishing the testing infrastructure.
Existing components and pages are not yet covered by tests and can be addressed incrementally in future PRs.

Closes #696

@github-actions
Copy link

github-actions bot commented Jan 2, 2026

❌ Checks Failed

Status: 🚫 Not ready to merge

Please fix the following issues before merging:

📝 Code Linting Failed

Issue: Code formatting or style violations detected.

Specific problems:

• TypeScript linting failed
• Code formatting issues detected

How to fix:

Platform Command Description
🐧 Unix/macOS/Linux npm run format Auto-fix all formatting issues
🪟 Windows npm run format:file <filename> Fix specific files
🔍 Check Only npm run format:check Check formatting without fixing

Need help with linting? Check out the Linting Guide for Windows Users for detailed instructions.


🛠️ Next Steps

  1. Fix the issues mentioned above
  2. Test locally to ensure everything works
  3. Push your fixes to this branch
  4. Wait for re-check - This bot will automatically run again

🤖 This comment will be updated automatically when you push new commits

@github-actions
Copy link

github-actions bot commented Jan 2, 2026

❌ Checks Failed

Status: 🚫 Not ready to merge

Please fix the following issues before merging:

📝 Code Linting Failed

Issue: Code formatting or style violations detected.

Specific problems:

• Code formatting issues detected

How to fix:

Platform Command Description
🐧 Unix/macOS/Linux npm run format Auto-fix all formatting issues
🪟 Windows npm run format:file <filename> Fix specific files
🔍 Check Only npm run format:check Check formatting without fixing

Need help with linting? Check out the Linting Guide for Windows Users for detailed instructions.


🛠️ Next Steps

  1. Fix the issues mentioned above
  2. Test locally to ensure everything works
  3. Push your fixes to this branch
  4. Wait for re-check - This bot will automatically run again

🤖 This comment will be updated automatically when you push new commits

@github-actions
Copy link

github-actions bot commented Jan 2, 2026

🎉 All Checks Passed!

Status: ✅ Ready to merge

✅ Completed Workflows

Workflow Status Details
🔨 Continuous Integration ✅ Passed Build completed successfully
📝 Code Linting ✅ Passed All formatting and style checks passed

🚀 This PR is ready for review and can be safely merged to main branch!

Great work! Your code meets all quality standards. 👏

@Pranav92005
Copy link
Contributor Author

Hi! I’ve opened a PR that adds a Vitest-based testing setup and fixes import.meta.glob alias issues that were preventing tests from running.
Happy to iterate or add coverage if needed.

@sa-fw-an sa-fw-an closed this Jan 4, 2026
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.

Implement Unit Testing Framework (Vitest)

2 participants