Vitest Testing Assignment
Objective
Learn to write and run tests using Vitest by following the step-by-step guide and completing the practice exercises.
Assignment Overview
You will work through the Vitest learning guide, setting up a testing environment and writing tests for functions. This assignment will teach you the fundamentals of test-driven development and how to use Vitest as a testing framework.
Instructions
Step 1: Access the Learning Guide
📖 Start here: Vitest Learning Guide - Level 1
📚 Full Guide: Navigate through all 46 levels using the navigation links at the top of each page.
Note: The guide is broken into multiple levels. Start at Level 1 and work through each level sequentially using the navigation at the top of each page.
Step 2: Complete the Setup
Follow Level 1 to:
- Initialize an npm project
- Install Vitest
- Configure your
package.json for ES6 modules
- Verify your setup works
Step 3: Work Through the Guide
Complete all levels in the guide:
- Levels 1-7: Introduction and setup
- Levels 8-22: Adding more tests and edge cases
- Levels 23-35: Red-green-refactor cycle
- Levels 36-46: Challenge exercises (building and composing functions)
Use the navigation links at the top of each page to move between levels.
Step 4: Complete Challenge Levels
The challenge levels (marked with ⚡ in navigation) require you to:
- Build functions from scratch
- Write tests first (red-green-refactor)
- Compose functions together
- Choose your own function cluster to practice
Required Deliverables
Submit the following through Moodle:
- GitHub Repository Link
- Create a new repository for your Vitest practice
- Include all your test files and function files
- Make sure the repository is public or shared with your instructor
- Screenshot of Passing Tests
- Show all tests passing (green) in your terminal
- Include at least 10+ passing tests
- Code Examples
- Share at least 3 function files with their corresponding test files
- Include examples from the challenge levels
- Brief Reflection (2-3 paragraphs)
- What did you learn about testing?
- How does writing tests first (red-green-refactor) change your coding process?
- What challenges did you face, and how did you overcome them?
Grading Criteria
- 40% - Setup and Configuration (Vitest installed, package.json configured correctly)
- 30% - Test Coverage (At least 10 passing tests covering various scenarios)
- 20% - Challenge Completion (At least 2 challenge levels completed)
- 10% - Code Quality (Clean, readable code with proper function structure)
Total: 100 points
Resources
Tips
- Start with Level 1 and work sequentially
- Don’t skip ahead - each level builds on previous concepts
- Use the “Show Me” sections if you get stuck
- Practice the red-green-refactor cycle on the challenge levels
- Test edge cases (empty strings, zero, negative numbers, etc.)
Questions? Review the complete Vitest guide or ask in the discussion forum.
Good luck! 🧪