You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ts-minitest

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-minitest

> A simple assertion and testing library with only one dependency - [`picocolors`](https://www.npmjs.com/package/picocolors). > Built to be small and easy to include in environments where running a full-fledged test runner may be difficult > to set up.

1.1.0
latest
npmnpm
Version published
Weekly downloads
49
-82.25%
Maintainers
1
Weekly downloads
 
Created
Source

MiniTest (TS)

A simple assertion and testing library with only one dependency - picocolors. Built to be small and easy to include in environments where running a full-fledged test runner may be difficult to set up.

  • Mimics part of the Jest expect() API.
  • Supports both ESM and CommonJS

Screenshot 2023-02-18 165948

Installation

npm install --save-dev ts-minitest

Usage

Anywhere in your code where you want to run tests, import the library and describe your tests. These tests will run immediately, emit any errors to the console.

import { it, describe, expect } from "ts-minitest";

describe("my test suite", () => {
    it("should throw an error if the assertion fails", () => {
        expect(true).toBe(false);
    });
    
    it("should not throw an error as the assertion passes", () => {
        expect(true).toBe(true);
    });
});

Intention

This library was built to be small and easy to include in any environment where you just need to run a few quick tests programmatically. It is not intended to be a full-fledged test runner, and does not have any of the comforts that you would have from a full-fledged test runner like Jest or Vitest.

A good use case would be if you need tests to run in the browser. For example, for running a suite of tests on request by the user or developer.

// local-storage.test.ts
import { it, describe, expect } from "ts-minitest";

describe("local storage", () => {
    it("should have a session ID", () => {
        const sessionId = window.localStorage.getItem("session-id");
        expect(typeof sessionId).toBe("string");
        expect(sessionId.length).not.toBe("");
    });
});

FAQs

Package last updated on 26 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts