npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

typescript-tdd

v1.2.5

Published

workshop utility for testing TypeScript code using TDD approach.

Downloads

2

Readme

Lines of Code Coverage Technical Debt Quality Gate Status Reliability Rating Duplicated Lines (%) Vulnerabilities Security Rating

Test-Driven Development (TDD) with Typescript

Welcome to our project! In this README, we'll introduce you to Test-Driven Development (TDD) and explain how it plays a crucial role in our development process.

What is Test-Driven Development (TDD)?

Test-Driven Development (TDD) is a software development approach where developers write tests for their code before writing the actual implementation. The TDD cycle typically consists of three steps: "red," "green," and "refactor."

  1. Red: In the "red" phase, developers write a failing test case that describes the desired behavior of the code. This test will fail initially because there is no implementation to satisfy it.

  2. Green: In the "green" phase, developers write the minimum amount of code necessary to make the failing test pass. The goal is to write code that satisfies the requirements of the test.

  3. Refactor: In the "refactor" phase, developers refactor the code to improve its design, readability, and performance while ensuring that all tests continue to pass. This step helps maintain clean and maintainable code.

Why Use Test-Driven Development?

Test-Driven Development offers several benefits to developers and teams:

  • Improved Code Quality: TDD encourages developers to focus on writing clean, modular, and testable code from the outset, leading to higher-quality software.

  • Faster Feedback Loops: TDD provides rapid feedback on code changes by running tests automatically. This allows developers to catch and fix issues early in the development process.

  • Regression Prevention: With a comprehensive suite of tests in place, developers can refactor code confidently without worrying about introducing new bugs.

  • Better Documentation: Test cases serve as living documentation that describes the behavior of the code. This makes it easier for new developers to understand the system and for existing developers to maintain and extend it.

Getting Started with TDD

To get started with Test-Driven Development in our project, follow these steps:

  1. Write a Failing Test: Begin by writing a test case that describes the desired behavior of the code. Run the test to ensure that it fails as expected.

  2. Write the Minimum Code: Write the minimum amount of code necessary to make the failing test pass. Focus on implementing just enough functionality to satisfy the requirements of the test.

  3. Refactor: Once the test passes, refactor the code to improve its design, readability, and performance while ensuring that all tests continue to pass.

  4. Repeat: Continue this cycle for each new feature or change, writing failing tests, implementing code, and refactoring as needed.

By following the principles of Test-Driven Development, we aim to deliver high-quality software that meets the needs of our users while maintaining a robust and maintainable codebase.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

What things you need to install and how to install them:

  • Node.js (version X.X.X)
  • npm or yarn

Installing

A step-by-step series of examples that tell you how to get a development environment running.

  1. Clone the repository:

    git clone https://github.com/adnenre/Typescript-TDD
  2. Change directory to the project directory:

    cd TYPESCRIPT-tdd
  3. Install dependencies:

    npm install
    # or
    yarn install

Running the tests

Explain how to run the automated tests for this system.

npm test

Documentation

SonarCloud

usage

import { U } from "typescript-tdd";
    let max = 1000;
    let min = 1;

    // math utils
    let randomNumber = U.math.RandomRange({ min, max });    //  return number between min and max

    // string utlis
    let capitalized =  let a = U.Str.capitalize('hello world'); // Hello World


     // array utlis
    const items = [1, 2, 3];
    const myInstance = new U.Arr(...items);
    console.log(myInstance.getItems())                            // Output : [1, 2, 3]

Author

Adnen Rebai