Add Vitest testing framework and fix import.meta.glob paths #700
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
src/setupTests.ts)package.json:test(watch mode)test:run(CI mode)coverageimport.meta.globusage by replacing alias paths (@/) with Vite-compatible absolute/src/...paths in:posts-utils.tsauthor-utils.tsWhy this change
The
CONTRIBUTING.mdfile 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.globdoes 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