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 🙏

© 2025 – Pkg Stats / Ryan Hefner

fartest

v2.1.8

Published

A minimal, colorful and enjoyable test library for small applications

Downloads

134

Readme

FAst and smaRT TESTing

.. for those who want to enjoy simple and emoji-augmented tests without having to learn the whole ecosystem of a rich test library.

FarTest is an obvious, colorful and enjoyable test library for small applications. It does not do cool stuff like code coverage, but you'll learn to use in no time.

success

Installation

npm install --save-dev fartest

Usage

FarTest simplest API export one main function:

async function start(testName?: string, async testFunction: ({
	test?: (condition: boolean, description?: string) => boolean,
	same?: (a: any, b: any, description?: string) => boolean,
	different?: (a: any, b: any, description?: string) => boolean,
	stage?: (name: string) => void,
}) => void): number

The return value is the number of errors encountered during the test.

The testName parameter is optional but strongly recommanded if you run multiple tests.

The testFunction parameter is a function that can take up to four arguments:

  • test(condition: boolean, description?: string) - a general assertion checking. If condition is true then the assertion has succeeded, otherwise it failed.
  • same(a: any, b: any, name?: string) - check if two values are the same. When a and bare objects, execute a deep comparison. Values can be of any type: numbers, strings, arrays, maps, sets, ...
  • different(a: any, b: any, name?: string) - opposite of same ; check if two values are strictly unequal.
  • stage(name: string) - use it to group unit tests together.

And that's the whole API.

Basic example

Let's create a new test file (can be in Typescript or in pure JS):

import start from 'fartest'
// the name of the function (MyAwesomeTest) is the name of the test
// and is optional
start('My test', async function({stage, test, same, different}) {
  stage('Basic tests')
    test(1 == "1", "String and integer loose comparison")

    // will fail
    test(1 === "1", "String and integer strict comparison")
    
    // will fail as well
    same(1, "1", "String and integer strict comparison (using same)")

  stage('Comparing objects')
    // deep comparison is done
    same({x: 1, y: 2}, {x: 1, y: 2}, "Deep object comparison")
    // the object type is also checked
    different(['foo'], {0: 'foo'}, "Array is not an object")
})

Then run it using node or a tool like esrun if your file is written in Typescript or in modern JS.

fail

Critical errors

Any invalid code will be caught and printed as a critical error.

start('Bold test', async function({stage, test}) {
  stage('It gotta works!!')
    undefined.x == 12
})

critical-fail

Test asynchronous functions

Because your main test functions is declared as async you can just use await anywhere you need it.

Running multiple tests

You can run multiple tests at once, in which case they all will be executed simultaneously - the fastest tests will display their results first.

// test 1
start('Slow test', async function({stage, test}) {
  stage('Basic tests')
  // let's wait 1 second
  await new Promise(resolve => setTimeout(resolve, 1000))
  test(1 == "1", "String and integer loose comparison")
})

// test 2
start('Instant test', async function({stage, test}) {
  stage('Basic tests')
  test(1 == "1", "String and integer loose comparison")
})

asynchronous

Conclusion

Congratulations, you've learned a new test library in less that 5 minutes!

What are you waiting for?

Enjoy testing 😌