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

twerp

v1.0.10

Published

Really simple, class based testing framework for node and Coffeescript.

Downloads

82

Readme

Twerp

Really simple, class based testing framework for node and Coffeescript.

Synopsis

npm install twerp

Written with coffeescript in mind so a really simple example use might be:

{ TwerpTest }    = require "twerp"

class exports.SimpleTest extends TwerpTest
  testSomethingSimple: ( done ) ->
    @ok 1

    # the optional message will help you when debugging failures
    @ok null, "Test that null is true"

    done( 2 )

  "test something else simple": ( done ) ->
    @equal 1, 2

    done( 1 )

class exports.AnotherSimpleTest extends TwerpTest
  "test stuff works as one might expect": ( done ) ->
    @isNull null
    @equal 1, 3 - 2, "Three minus two is one"

    done( 2 )

Then run with 'twerp' (you can run coffee directly) and you're off:

$ twerp blah.js

Writing tests

To build a test class you need to create a file containing at least one class which inherits from TwerpTest.

Any methods defined in your class which begin with "test" will be run as tests. Other than tests starting with "setup" or "teardown" you can call 'private' methods what you want. The callback received by each method must be called when it's finished and should also take the number of tests you expected to run.

Any methods that begin with "setup" will run before each test method and any that start with 'teardown' will run after each test method. setup will always run before other setup functions and teardown will always run before other teardown methods. The others will run in alphabetical order. So for example, with a class that looks like this:

class Hello
  "teardown webserver":
  teardown:
  setup:
  testOne:
  "setup database":
  "setup controllers":
  "setup application":
  testTwo:

The execution order will be:

  • setup
  • setup application
  • setup controllers
  • setup database
  • testOne
  • teardown
  • teardown webserver
  • setup
  • setup application
  • setup controllers
  • setup database
  • testTwo
  • teardown
  • teardown webserver

Tests will be run in order. No async magic here.

Choosing a runner

You can pick a runner (how the code is formatted) by using --runner= on the command line. For a list of available runners use --help.

Assertion functions

Bundled with twerp are the following assert functions:

As with assert.js

  • fail
  • ok
  • equal
  • notEqual
  • deepEqual
  • notDeepEqual
  • strictEqual
  • notStrictEqual
  • throws
  • doesNotThrow
  • ifError

As with assert-extras

  • isNull
  • isNotNull
  • isTypeOf
  • isNotTypeOf
  • isObject
  • isFunction
  • isString
  • isBoolean
  • isNumber
  • isUndefined
  • isNotUndefined
  • isArray
  • isNaN
  • isNotNaN
  • match
  • noMatch
  • isPrototypeOf
  • isNotPrototypeOf
  • isWritable
  • isNotWritable
  • isConfigurable
  • isNotConfigurable
  • isEnumerable
  • isNotEnumerable

options

  • --help: Help!
  • --exit-on-failure: Exit as soon as a class fails.
  • --no-colour: Turn off colour output.
  • --no-color: Turn off colour output if you're American.
  • --match-class: Only run classes whose names match STRING.
  • --match-function: Only run functions whose names match STRING.
  • --runner: How output should be formatted. --help for a list.