Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Super lightweight node module for running automated tests.
JavaScript
Tree: 0e2085f699

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tests
README.md
describe.js
package.json

README.md

describe

Describe provides a simple method for testing asynchronous and synchronous code within JavaScript projects.

API Documentation

describe

describe( groupName, tests[, options] );

Arguments

  • groupName (string): A human-readable description of the test group.
  • tests (object): An object made up of human-readable test descriptions as keys and functions to run as tests. Tests functions will be given access to this.expect.
  • options: Configuration options. Possible values:
    • timeout (int): The max amount of time to wait for a test to run before timing out.
    • callbackMode (string): if set to 'node', this.expect will treat the first argument to the callback as an error and the second argument as the result.

describe.config

describe.config( key, value )

Sets the global configuration for tests.

Synchronous Assertions

this.expect( subject, expected )

Arguments

  • subject (mixed): the actual result.
  • expected (mixed): the expected result.

Example

describe("assertions", {
    'basic synchronous expectation': function() {
        this.expect(42, 42);
    }
});

Asynchronous Assertions

this.expect( expected )

Example: Basic Callbacks

function addNumbersAsync(a, b, callback) {
    callback(a+b);
}

describe("assertions", {
    'basic asynchronous expectation': function() {
        addNumbersAsync(2, 2, this.expect(4));
    }
});

Example: Node.js-style (e, data) Callbacks

function addNumbersAsync(a, b, callback) {
    callback(null, a+b);
}

describe("assertions", {
    'basic asynchronous expectation': function() {
        addNumbersAsync(2, 2, this.expect(4));
    }
}, { callbackMode: 'node' });
Something went wrong with that request. Please try again.