Page MenuHomePhabricator

Implement Vitest for Unit Testing Utility Functions
Closed, ResolvedPublic

Description

Domain: Coding

Difficulty: Intermediate

Description: Currently, the project lacks unit tests, making it difficult to verify the correctness of individual functions and hooks in isolation. As outlined in the roadmap, this task involves setting up the Vitest testing framework to enable fast and efficient unit testing.

Expected Outcome:

  • vitest and jsdom are added as dev dependencies.
  • A vitest.config.ts file is created and configured for the project.
  • At least one utility function (e.g., from utils/utils.ts) has a corresponding .test.ts file with passing tests.
  • The package.json scripts section includes a new test command that runs Vitest.

Links or References:

Setup Steps:

  1. Run npm install -D vitest jsdom @testing-library/react.
  2. Create vitest.config.ts at the project root.
  3. Create a tests directory within src for unit and integration tests.
  4. Write a test file for a simple utility, such as src/utils/debounce.ts.
  5. Run npm test and ensure it passes.

Event Timeline

Collins renamed this task from Implement Vitest for Unit Testing to Implement Vitest for Unit Testing Utility Functions.

Change #1219919 had a related patch set uploaded (by Bovimacoco; author: Bovimacoco):

[labs/tools/WdTmCollab@main] Implement Vitest for Unit Testing Utility Functions

https://gerrit.wikimedia.org/r/1219919

Change #1219919 merged by jenkins-bot:

[labs/tools/WdTmCollab@main] Implement Vitest for Unit Testing Utility Functions

https://gerrit.wikimedia.org/r/1219919

Collins closed this task as Resolved.EditedDec 19 2025, 7:27 PM

@Bovimacoco, thank you for the implementation.