stonefly

0.0.9 • Public • Published

Stonefly.js

Stonefly.js is a minimalist unit test framework for Node.js projects using Require.js.

Installation

API

Describing a collection of tests (a suite)

define( function( requirejs )
{
    
    // Grab an instance of Stonefly
    var Stonefly = require( 'stonefly' );
    
    Stonefly.describe( "Math floor function", function()
    {
    
        // Test that the floor function given a value greater than zero and less than 1
        // returns a 0 value.
        Stonefly.it( "Math floor function returns zero for 0.1", function( done )
        {
            Stonefly.expect( Math.floor( 0.1 ) ).toBe( 0 );
            done();
        } );
        
        // Test that the floor of 0.9 resolves to something other than 1
        Stonefly.it( "Math floor functions return not 1 for 0.9", function( done )
        {
            Stonefly.expect( Math.floor( 0.9 ) ).notToBe( 1 );
            done();
        } );
        
        // Guarantee that the Math function actually exists
        Stonefly.it( "Math floor function exists", function( done )
        {
            // Expect can be used alone to just evaluate a value's truthiness
          Stonefly.expect( Math );
          Stonefly.expect( Math.floor );
          done();
        } );
        
    } );
    
    // Once all suites have been described and all tests, tell Stonefly to run.
    // runAndExit will execute tests and then exit the process with a success code
    // if the tests succeed and a failure code if they do not.
    Stonefly.runAndExit();
    
} );

License

MIT License

Readme

Keywords

none

Package Sidebar

Install

npm i stonefly

Weekly Downloads

1

Version

0.0.9

License

MIT

Last publish

Collaborators

  • centaur2048