Skip to content

Latest commit

Β 

History

History
129 lines (90 loc) Β· 4.24 KB

File metadata and controls

129 lines (90 loc) Β· 4.24 KB

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