Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
simple js framework to run unit tests/behaviors
JavaScript Shell
Branch: master
Failed to load latest commit information.
.nuget
jMoney added printSummart() function
lib adding new dirs
.gitignore Added .gitignore, update output to inclide spec name
README.markdown Update README.markdown
jmoney.tests.html updated readme to include info on creating custom predicates
minme.bat

README.markdown

Note: tests render in console. Best used with FF3+

API

  • toBe(value)

  • toBeTrue()

  • toBeNull()

  • toBeUndefined()

  • toMatch(regex)

  • toBeNumeric()

.not() can be prepended to any matcher.

.not().toBeTrue()

Simple usage

when.('Using numbers', function() {
    spec('7 should be numberic').expect(7).toBeNumeric();
});

var returnSeven = function() {
    return 7;
};

when.('Using returnSeven', function() {
    spec('Should return 7').expect(returnSeven()).toBe(7);
    spec('Should return numeric value').expect(returnSeven()).toBeNumeric();
});

when('Using anonymous functions', function() {
    spec('Should return the number 7').expect(function() {
        return 7;
    }).toBe(7);
}):

printSummary();

Creating your own matcher (predicate)

jn.Predicates.fn.toBeFoo = function(expected) {
    //expected can either be passed in as an argument i.e toBeFoo('this is the expected value');
    //Or can be explicitly set like so:
    this.expected = 'foo';
    return this.expected === this.actual; //this.actual is the returned value from the expect function
};

Using it

when('Using toBeFoo', function() {
    spec('Should be success when function returns foo').expect(function() {
        return 'foo';
    }).toBeFoo();
}):
Something went wrong with that request. Please try again.