/javascript-testing-jsexpert

JavaScript test suite with mocks, stubs, spies, end-to-end with coverage and TDD in the JS Expert.

Primary LanguageJavaScript

JavaScript Testing JS Expert

๐Ÿ‘จโ€๐Ÿ’ป Developed by Matheus Ramalho de Oliveira
๐Ÿ—๏ธ Brazilian Software Engineer
โœ‰๏ธ kastorcode@gmail.com
๐Ÿฆซ LinkedIn โ€ข Instagram


This repository contains a comprehensive collection of JavaScript testing practices and examples, covering various testing methodologies and techniques. The project is structured to help developers understand and implement different testing approaches in JavaScript applications.


๐Ÿ—‚๏ธ Project Structure

The project is organized into several modules, each focusing on specific testing concepts:

  • 01-mocks: Examples and implementations of mocking in JavaScript tests
  • 02-stubs: Demonstration of stub usage in testing
  • 03-spies: Implementation of test spies and their applications
  • 04-coverage-e2e: End-to-end testing examples with coverage reporting
  • 05-tdd-project: A simple project built using Test-Driven Development (TDD) principles

๐Ÿš€ Getting Started

Prerequisites

  • Node.js (version 18 or higher)
  • npm or yarn package manager

Installation

  1. Clone this repository:
git clone https://github.com/kastorcode/javascript-testing-jsexpert.git
cd javascript-testing-jsexpert
  1. Install dependencies for each module as needed:
cd [module-name]
npm install
# or
yarn install

๐Ÿงช Running Tests

Each module contains its own test suite. To run tests for a specific module:

cd [module-name]

npm test
# or
yarn test

npm test:cov
# or
yarn test:cov

๐Ÿ“š Learning Objectives

  • Understanding and implementing different types of test doubles (Mocks, Stubs, Spies)
  • Writing effective unit tests
  • Implementing end-to-end testing
  • Following Test-Driven Development practices
  • Measuring and improving test coverage
  • Best practices in JavaScript testing

<kastor.code/>