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

goiabada

v0.1.1

Published

Experimental es6 unit tests project

Downloads

5

Readme

Goiabada

This is an experimental project providing a very simple (and incomplete) unit test tool written using ES6 features.

goiaba

Rationale

I saw a lot of people very excited with the new changes on babel (6to5) and after talking to some friends at work, I decided to play with some ES6 doing this unit test framework using a lot of its features.

So far it's using several ES6 features together, like:

  • Classes
  • Promises
  • Generators (++ to this one as it solved the async tests order like a charm)
  • Arrow functions
  • template strings
  • parameters destructuring
  • shorthand properties

Reviews, comments and PR are more than welcome! I'll love any feedback.

Development

Clone it!

git clone [email protected]:leobalter/goiabada.git

Install npm dependencies

npm install

Run npm test to see it working.

Usage

Import goiabada and instantiate a new object:

import Goiabada from "goiabada";

var goiabada = new Goiabada();

Write your tests using the test method, catch the assert parameter and write your assertions, then call end() when you're done testing.

goiabada.test( assert => {
    assert.ok( true, "it works!" );
    assert.end();
});

If you prefer calling only test, without the namespace, you can add this line:

var test = goiabada.test.bind( goiabada );

Browser

Goiabada uses a Browserify build for browser usage.

TODO: more documentation on that

API

Assertions:

  • ok( value[, message ] ): evaluates the value to true. e.g.: true, 1 or "non-empty string".
    • Returns the result.
  • notOk( value[, message ] ): evaluates the value to false.
    • Returns the result.
  • equal( value, expected[, message ] ): non strict comparison (==).
    • Returns the result.
  • notEqual( value, expected[, message ] ): negative non strict comparison (!=).
    • Returns the result.
  • same( value, expected[, message ] ): strict comparison (===).
    • Returns the result.
  • notSame( value, expected[, message ] ): negative strict comparison (!==).
    • Returns the result.
  • throws( fn[, message ] ): passes when the given fn throws an error.
    • Returns the error.

Helpers

  • expect( n ): expects a number of given assertions to run from that point.
    • The last expected assertion will trigger the end() method.
  • end(): when triggered manually, it will close the test and:
    • trigger an error if you still have remaining tests set from expect();
    • trigger an error for each of consecutive assertion in the same test block.
  • remaining: if you call expect(n), this will receive a number value with the remaining tests to run.
  • error: push an error to the test log

Logs

  • assertions: the executed assertions
  • passed: the passing assertions
  • failed: the failing assertions

The Logger

You can set a different logger on Goiabada. It's not standardized yet but my goal is to follow the possible conventions from https://github.com/js-reporters/js-reporters