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 🙏

© 2024 – Pkg Stats / Ryan Hefner

testit.run

v1.1.3

Published

minimalistic client-side testing library

Downloads

3

Readme

Test.it

A minimalistic client-side testing library

Test.it is a small client-side testing library for people that want to live in code, not in tests. No over engineering here. Inspired by the simplicity of libraries like Jasmine, but implementation ideas based on TinyTest

This is probally not a cure-all testing solution, if you want something more robust checkout Jasmine, Tape or Mocha -- this is to...

Test small things, with small things

Features

  • Designed for the Browser
  • Under a 100 lines
  • Single File
  • No Dependicies
  • 2kb footprint (before gzip)
  • Extend with custom reporters
  • Uses Simple Assert

No Bloat Here!

Usage

By default, you can run your tests like

import test from 'testit';

test.it({
    'my passing test': function() {
        test.assert(true);
    },
    'my failing test': function() {
        test.assert(true === false, 'just wanted to fail fast');
    }
}).run();

NOTE: run() can be called elsewhere, see tests/

by default, your test results are logged to the console

+OK my passing test
-ERR my failing test
---
Error: just wanted to fail fast
    ...error stack...
---

# tests 2 pass 1 fail 1

A +OK will proceed test lines that pass and a -ERR for those that fail, An error stack is included by default after the failing test wrapped in ---. You can suppress outputing the error stack by passing false as an argument to run(), ie run(false).

You can, also, write your own custom test runner...

Custom Test Runners

test.it .run() method provides an optional next function parameter that passes the results as an object for you to process however you like.

For Example...

For Fans of TinyTest

test.it({
    'my passing test': function() {
        test.assert(true);
    }
}, function(results) {
    if (window.document && document.body) {
        document.body.style.backgroundColor = (
            results.fail.length ? '#ff9999' : '#99ff99'
        );
    }
});

If using the optional next param will return results as JSON

{
    "pass": ["list of passed tests", "..."],
    "fail": ["list of errored tests", "..."],
}

From this object you can easily find the number of tests ran pass.length, number of failed tests fail.length or the total test count by adding the two. Simple.

REMEMBER: you can bypass error output too

A sample test runner is provided for the BROWSER in the test/ directory; index.html and runner.js respectfully, with the spec in index.spec.js.

Methods

To stay minimal, test.it only has 3 core functions:

  • it to capture your tests
  • run to execute yours tests
  • and assert to write your assertions

While you can use your own assertion library, the included assert evaluates an expression/condition tests:

if you want to shorten test typing try

let assert = test.assert;

putting that above your tests will allow you to write like

test.it({
    "my test should work": function() {
        assert(true);
    }
});

TODO

  • provide sample test runner for CI environments
  • maybe spec files export results && runner identifies failure

Support

Please open an issue for support.

Contributing

Anyone is welcome to contribute, however, if you decide to get involved, please take a moment to review the guidelines, they're minimalistic;)

License

MIT Geoff Doty