Dexter is a simple Test Helper, framework independent.
Pull request Compare This branch is 118 commits behind leobalter:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist
libs/qunit
src
test
LICENSE-GPL
LICENSE-MIT
README.md
grunt.js
package.json

README.md

Dexter JS

Dexter is a simple Test Helper, framework independent.

Getting Started

Download the production version or the development version.

Documentation

This's a Test Helper. With Dexter, you can spy functions and create stubs to prevent their default functionality and set callbacks to create your assertions.

It's like Sinon.JS, but this is VERY simple. The goal is to keep it simple and clean.

Fake Ajax handling is comming soon.

(More documentation coming soon)

Examples

Dexter.spy

var spy = Dexter.spy( console, 'log' );

// Spy doesn't prevent function calls but register them.
console.log( '123' );

spy.called; // 1

// you can restore the spied method to it's default functionality
stub.restore(); 

Dexter.stub

var stub = Dexter.stub( console, 'log', function() {
    // please don't ever consider stubbing console.log to make an alert call
    // this is only a cheap example
    alert( 'stub called!' );

    // you can also catch the call arguments
});

// Stub prevent default function calls and you can trigger a callback function
console.log( '123' ); // 'stub called!';

stub.called; // 1

// you can restore the stubbed method to it's default functionality
stub.restore(); 

Release History

2012-07-11 - initial release, stub and spy ready and tested

License

Copyright (c) 2012 Leonardo Balter
Licensed under the MIT, GPL licenses.

Contributing

  1. In lieu of a formal styleguide, take care to maintain the existing coding style and please do follow idiomatic.js.
  2. Add unit tests for any new or changed functionality.
  3. Lint and test your code using grunt.

Important notes

Please don't edit files in the dist subdirectory as they are generated via grunt. You'll find source code in the src subdirectory!

While grunt can run the included unit tests via PhantomJS, this shouldn't be considered a substitute for the real thing. Please be sure to test the test/*.html unit test file(s) in actual browsers.

Installing grunt

This assumes you have node.js and npm installed already.

  1. Test that grunt is installed globally by running grunt --version at the command-line.
  2. If grunt isn't installed globally, run npm install -g grunt to install the latest version. You may need to run sudo npm install -g grunt.
  3. From the root directory of this project, run npm install to install the project's dependencies.

Installing PhantomJS

In order for the qunit task to work properly, PhantomJS must be installed and in the system PATH (if you can run "phantomjs" at the command line, this task should work).

Unfortunately, PhantomJS cannot be installed automatically via npm or grunt, so you need to install it yourself. There are a number of ways to install PhantomJS.

Note that the phantomjs executable needs to be in the system PATH for grunt to see it.