NAME

jsTestMore v1.11 - A simple test framework for javascript


SYNOPSIS

    testmore.ui.browser("testoutput");
    make_plans(function () {
        plan(9,"These tests should all be OK.", function() {
            ok(true,"boolean");
            ok(!false,"boolean2");
            is(300,300,"is number");
            is("blabla","blabla","is string");
            isnt(300,350,"isnt number");
            isnt("blabla","bliepbliep","isn't string");
            can("blabla","toString","can");
            like("blabla",/bla/,"like");
            unlike("blabla",/other/,"unlike");
        });
        plan(9,"These tests should all fail.", function() {
            ok(false,"boolean");
            ok(!true,"boolean2");
            is(305,300,"is number");
            is("blabla","bliepbliep","is string");
            isnt(300,300,"isnt number");
            isnt("blabla","blabla","isn't string");
            can("blabla","doesntExist","can");
            like("blabla",/other/,"like");
            unlike("blabla",/bla/,"unlike");
        });
        plan(4,"Test 1 and 3 should fail, 2 and 4 should succeed.", function() {
            ok(false,"boolean");
            ok(true,"boolean2");
            is(305,300,"is number");
            is("blabla","blabla","is string");
        });
        
    });

DESCRIPTION

jsTestMore gives you a basic framework to test your javascript code.

The webpage for this library is at http://zeekat.nl/downloads/jstestmore/


OUTPUT FORMAT

testmore.ui.browser()
    testmore.ui.browser(elementId)

Set up the jsTestMore framework to give output an a browser. All output is appended to the element refered to by elementId. This format uses the W3C Level 1 DOM. Most current browser should support it.

If you can't use the test methods below, you probably haven't called this method: the test methods are generated based on the type of output: no ouput type == no test methods.

There are currently no other output formats. It should be reasonably easy to add more. See the code.

PLANNING

make_plans
    make_plans(function() {
        // your plans here
    });
plan()
    plan( numberOfTests, planName, function() {
        // your tests here
    });

Run a series of numberOfTests tests with title planName. If numberOfTests is -1, no exact number of tests is expected.

no_plan()
    no_plan(planName, function() {
        // your tests here
    });

Run a series of tests with title planName. Equivalent to

    plan(-1, planName function() {
        // your tests here
    });

TEST METHODS

ok
    ok( expression, title );

Test succeeds if expression is true.

is
    is( expression, expected, title);

Test succeeds if expression == expected

isnt
    isnt( expression1, expression2, title);

Test succeeds if expression1 != expression2.

can
    can( object, "methodName", title);

Test succeeds if object has a method ``methodName''.

like
    like( string, /regex/, title);

Test succeeds if string.match(/regex/).

unlike
    like( string, /regex/, title);

Test succeeds if !string.match(/regex/).


BUGS / TODO

No bugs are know at the moment. Future versions should implement more of the Test::More API, and will probably support different output formats.


CHANGES

    1.00 - initial version
    1.10 - added stacktrace to report if available.
           improved string conversion of arguments.
           added make_plans handler.
    1.11 - slight adjustments to output format

SEE ALSO

The Test::More module on CPAN:

http://search.cpan.org/~mschwern/Test-Simple/lib/Test/More.pm


COPYING

Copyright (c) 2005 Joost Diepenmaat, Zeekat Softwareontwikkeling, all rights reserved.

http://zeekat.nl/

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ``Software''), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.