Skip to content

top-submissions/fullstackjs-testing-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Testing Practice

License The Odin Project

A hands-on exploration of Test-Driven Development (TDD) using Jest as part of The Odin Project curriculum. This repository documents my learning journey through writing comprehensive unit tests for various JavaScript functions.

📋 Table of Contents

✨ Features

  • String Utilities - capitalize() and reverseString() functions with full test coverage
  • Calculator Object - Basic arithmetic operations (add, subtract, multiply, divide) with comprehensive tests
  • Caesar Cipher - Character shifting cipher with case preservation and wrapping logic
  • Array Analysis - Statistical analysis function returning average, min, max, and length
  • Test-Driven Development - All functions implemented using TDD methodology with Jest

🚀 Getting Started

Want to run this project locally? Here's how:

Prerequisites

  • Node.js (version 14 or higher)
  • npm (comes with Node.js)
  • Basic understanding of JavaScript and unit testing

Installation

  1. Clone the repository
   git clone https://github.com/top-submissions/fullstackjs-testing-practice.git
   cd fullstackjs-testing-practice
  1. Install dependencies
   npm install
  1. Verify installation
   npm test

Running Tests

Run all tests:

npm test

Run tests in watch mode:

npm test -- --watch

Run tests with coverage:

npm test -- --coverage

💡 Future Improvements

If I were to continue working on this project, here's what I'd add:

  • Add edge case tests for division by zero
  • Implement integration tests for combined function usage
  • Add performance benchmarks for array analysis with large datasets
  • Implement additional cipher algorithms (ROT13, Vigenère)
  • Add TypeScript support with type definitions
  • Create visual test coverage reports
  • Add continuous integration with GitHub Actions
  • Implement property-based testing with fast-check

📚 What I Learned

  • Test-Driven Development - Writing tests first helps clarify requirements and leads to better code design
  • Jest Framework - Mastered Jest's testing syntax, matchers, and test organization with describe/test blocks
  • Edge Case Handling - Importance of testing boundary conditions, empty inputs, and invalid data
  • Code Coverage - Understanding what code coverage metrics mean and how to achieve comprehensive test coverage
  • Modular Design - Structuring code into small, testable functions with single responsibilities
  • Array Methods - Leveraging reduce(), map(), and spread operators for elegant solutions
  • Character Encoding - Working with character codes and ASCII values for the Caesar cipher implementation

🛠️ Technologies Used

  • Jest - JavaScript testing framework
  • Babel - JavaScript transpiler for ES6+ support
  • Node.js - JavaScript runtime environment
  • ES6 Modules - Modern JavaScript module system

🔗 Resources

🙏 Acknowledgments

  • The Odin Project - For providing an amazing free curriculum

Built with 💡 and ☕ as part of my journey through The Odin Project