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 🙏

© 2026 – Pkg Stats / Ryan Hefner

intuitive-test-assertions

v1.1.8

Published

Intuitive Assertions

Readme

npm downloads checks follow

Intuitive Assertion

Install the Intuitive test assertions package in your application

npm i intuitive-test-assertions

Available assertions

Intuitive assertions are available for different types in TypeScript language. Start using library importing intuitive-test-assertions in your file

// *.test.ts file
import 'intuitive-test-assertions';

After importing this library you are able to use Intuitive Test Assertions in your tests.

Boolean

// *.test.ts file
import 'intuitive-test-assertions';

function foo(): boolean {
    return true;
}

const bool = foo();

bool.must().be(true);
bool.must().beTrue();
// if you want to verify something opposite, use the not property
bool.must().not.beFalse();
bool.must().not.be(false);

bool.must().beFalse(); // the message will be thrown: 'Expected value to be 'False', but found 'true''

Number

// *.test.ts file
import 'intuitive-test-assertions';

function foo(): number {
    return 5;
}

const numb = foo();

numb.must().be(5);
numb.must().beGreaterOrEqualTo(5);
numb.must().beGreaterThan(4);
numb.must().beLesserOrEqualTo(5);
numb.must().beLesserThan(6);
numb.must().beInRange(0, 10);
numb.must().beInteger();
numb.must().bePositive();
// if you want to verify something opposite, use the not property
numb.must().not.beNegative();

numb.must().beInRange(10, 12); // the message will be thrown: 'Expected value '5' to be between '10' and '12', but value is out of this range'

Array

// *.test.ts file
import 'intuitive-test-assertions';

function foo(): Array<number> {
    return [ 1, 2, 3, 4, 5, 6 ];
}

const arr = foo();

arr.must().be([ 1, 2, 3, 4, 5, 6 ]);
arr.must().not.beEmpty();
arr.must().beSortedInASC();
// if you want to verify something opposite, use the not property
arr.must().not.beSortedInDESC();
arr.must().contains(3);
arr.must().containsType('number');
arr.must().endsWith([ 4, 5, 6 ]);
arr.must().equalsTo([ 1, 2, 3, 4, 5, 6 ]);
arr.must().haveLength(6);
arr.must().haveLengthEqualOrGreaterThan(5);
arr.must().haveLengthEqualOrLesserThan(7);
arr.must().haveSameLengthAs([ 1, 2, 3, 4, 5, 6 ]);
arr.must().startsWith([ 1, 2, 3 ]);

arr.must().haveSameLengthAs([ 's', 's', 's']); // the message will be thrown: 'Expected collection has length '3', but found '6''

Object

// *.test.ts file
import 'intuitive-test-assertions';

function foo(): Object {
    return { firstElement: 1, secondElement: null, thirdElement: undefined };
}

const obj = foo();

// if you want to verify something opposite, use the not property
obj.must().not.beEmpty(); 
obj.must().contains((object) => object.subject.firstElement === 1);
obj.must().containsKey('secondElement');
obj.must().containsNullOrUndefined();
obj.must().haveLength(3);
obj.must().haveLengthEqualOrGreaterThan(2);
obj.must().haveLengthEqualOrLesserThan(4);

obj.must().contains((obj) => obj.subject.firstElement === 5 ) // the message will be thrown: 
// 'Expected collection { obj.subject.firstElement === 5; }, but found {"firstElement":1,"secondElement":2,"thirdElement":3}}'

Date

// *.test.ts file
import 'intuitive-test-assertions';

function foo(): Date {
    return new Date(2022, 1, 1, 10, 55, 15);
}

const date = foo();

date.must().be(new Date(2022, 1, 1, 10, 55, 15));
date.must().beAfter(new Date(2022, 1, 1, 9, 55, 15));
date.must().beBefore(new Date(2022, 9, 17));
date.must().beInDateRange(new Date(2021, 12, 31), new Date(2022, 12, 31));
date.must().beOnOrAfter(new Date(2022, 1, 1, 8, 55, 15));
date.must().beOnOrBefore(new Date(2022, 1, 1, 11, 55, 15));
date.must().beOneOf([ new Date(2022, 1, 1, 10, 55, 15), new Date(2022, 1, 1, 9, 55, 15), new Date(2022, 1, 1, 8, 55, 15) ]);
date.must().bePrecisely(new Date(2022, 1, 1, 10, 55, 15).getTime());
date.must().containsDate(1);
date.must().containsDayOfWeek(5);
date.must().containsHours(10);
date.must().containsMinutes(55);
date.must().containsMonth(1);
date.must().containsSeconds(15);
date.must().containsYear(2022);

date.must().beOneOf([ new Date(2000, 4, 13), new Date(2000, 4, 25) ]); // the message will be thrown: 
// 'Expected date be at least one of '"5/13/2000", "5/25/2000"', but found '1/1/2022''

String

// *.test.ts file
import 'intuitive-test-assertions';

function foo(): string {
    return 'Intuitive test assertions';
}

const str = foo();

str.must().be('Intuitive test assertions');
// if you want to verify something opposite, use the not property
str.must().not.beEmptyOrWhiteSpace();
str.must().contains('test');
str.must().containsAll([ 'Intuitive', 'test', 'assertions' ]);
str.must().containsAny([ 'Intuitive' ]);
str.must().endsWith('assertions');
str.must().startsWith('Intuitive');
str.must().hasLength(26);
str.must().match(/.+/gm);

str.must().beEmptyOrWhiteSpace(); // the message will be thrown: 
// 'Expected be empty or white space, but found 'Intuitive test assertions''

Function

Currently library provides some of asserts for functions. See examples bellow

// *.test.ts file
import 'intuitive-test-assertions';

function foo(): number {
    return 2;
}

foo.must().returnsType('number');
// if you want to verify something opposite, use the not property
foo.must().not.haveName('bar');

In the example below we are able to check if the function will be thrown. There are available two ways how you can do it

// *.test.ts file
import { must } from 'intuitive-test-assertions';

// function with parameters
function foo(a: number): number {
    if (a > 0) {
        return a;
    } else {
        throw new Error('Test is thrown');
    }
}

// must be asserted with following code
must(() => foo(-1)).beThrown();

// function without parameters
function bar(): number {
    return 10;
}

// can be asserted with both available ways
must(() => bar()).not.beThrown();
bar.must().not.beThrown();

Multiple assertion statements in one row

If you want to check something with two or more statements in one row use and property

// *.test.ts file
import 'intuitive-test-assertions';

function foo(): Array<number> {
    return [ 1, 2, 3, 4, 5, 6 ];
}

const arr = foo();

// if you want to check something with two or more statements in one row use and property
arr.must().not.beEmpty().and.haveLength(6);