Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tiny-jest

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-jest

Minimalistic zero dependency Jest-like test library to run tests in browser, nodejs or deno.

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

Tiny Jest

Minimalistic library to run Jest-like tests in any JS environment: browser, node or even deno. Perfect to run in sandboxes

Features

  • Zero dependency
  • Ultra fast
  • Clean Jest-like api
  • Runs in browser
  • Provides jest-like "expect" library, but can be used with any assert/expect library

Limitations

  • Doesn't include cli-runner
  • Included "expect" library has limited amount of matchers, much less than original Jest expect

Installation

NPM:

yarn add tiny-jest

or

npm install tiny-jest

CDN:

<script src="https://unpkg.com/tiny-jest/dist/bundle.js"></script>

Deno:

import {
  Test,
  expect,
  prettify,
} from "https://raw.githubusercontent.com/ValeriaVG/tiny-jest/v1.2.1/dist/mod.ts";

const { it, run, title } = new Test("basic");

it("2+2=4", () => {
  expect(2 + 2).toBe(4);
});

run().then(prettify);

Usage

For benchmarks and usage examples see benchmark folder.

const { it, run, title, before, after } = new Test("name-of-your-test");

before(async () => {
  // some setup
});
before(async () => {
  // some cleanup
});

it("toBe", () => {
  expect(2 + 2).toBe(4);
  expect(2 + 2).not.toBe(5);
});

it("toEqual", () => {
  expect(2 + 2).toEqual("4");
  expect(2 + 2).not.toEqual("5");
});

it("toBeTruthy", () => {
  expect(0).toBeFalsy();
  expect(1).not.toBeFalsy();
});

it("toBeFalsy", () => {
  expect(1).toBeTruthy();
});

it("toMatchObject", () => {
  expect({
    fullName: {
      givenName: "John",
      familyName: "Doe",
    },
  }).toMatchObject({
    fullName: {
      givenName: "John",
    },
  });
  expect({
    givenName: "John",
    familyName: "Doe",
  }).not.toMatchObject({
    fullName: {
      givenName: "John",
    },
  });
});

run().then(prettify);

Keywords

FAQs

Package last updated on 03 Nov 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc