yangshun / mini-jest

πŸƒ Attempt at writing my own minimal test runner with an API similar to Jest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mini-jest

Attempt at writing my own minimal test runner that implements a subset of the features of Jest.

Note: This is just an experiment for my own learning and is in no way meant to be used in production.

API

Similar to Jest. The describe, it, test, expect functions are exported.

Usage

It works for an example taken off Jest homepage:

const { describe, expect, it, test } = require('mini-jest');

const myBeverage = {
  delicious: true,
  sour: false,
};

describe('test that', () => {
  describe('my beverage', () => {
    test('is delicious', () => {
      expect(myBeverage.delicious).toBeTruthy();
    });

    test('is not sour', () => {
      expect(myBeverage.sour).toBeFalsy();
    });
  });
});

Example

$ npm test

> mini-jest@0.1.0 test /Users/yangshun/Developer/mini-jest
> node ./__tests__/meta.test.js

expect tests
  βœ” toBe works correctly (0ms)
  βœ” toBeFalsy works correctly (0ms)
  toBeGreaterThan works correctly
    βœ” with positive numbers (0ms)
    βœ” with negative numbers (0ms)
    βœ” with mixed numbers (0ms)
  toBeGreaterThanOrEqual works correctly
    βœ” with positive numbers (0ms)
    βœ” with negative numbers (0ms)
    βœ” with mixed numbers (0ms)
  toBeLessThan works correctly
    βœ” with positive numbers (0ms)
    βœ” with negative numbers (0ms)
    βœ” with mixed numbers (0ms)
  toBeLessThanOrEqual works correctly
    βœ” with positive numbers (0ms)
    βœ” with negative numbers (0ms)
    βœ” with mixed numbers (0ms)
  βœ” toBeNull works correctly (0ms)
  βœ” toBeTruthy works correctly (1ms)
  βœ” toBeUndefined works correctly (0ms)
  βœ” toContain works correctly (0ms)
  βœ” toHaveLength works correctly (0ms)

About

πŸƒ Attempt at writing my own minimal test runner with an API similar to Jest

License:MIT License


Languages

Language:JavaScript 100.0%