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.
Similar to Jest. The describe
, it
, test
, expect
functions are exported.
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();
});
});
});
$ 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)