JavaScript test framework for exercising an API
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

###JavaScript TestRunner###

This is a simple JavaScript test framework so I can exercise my API.

#####How it Works#####

Make a new testrunner

var tr = new TestRunner()

and a new test

tests['hello'] = new Test(function() { alert('hello') })

add the test to the testrunner


and finally


Put this file on your server and include the script into your code

<script src="/static/js/testrunner.js"></script>

After you include the script you are ready to add some tests

    // Make all ajax calls syncronous
        async: false

    var tests = []

    tests['login'] = new Test(
    function() {
        $.post('/qliqserver/login', {'username':<username>, 'password':<password>},
        function(data) {
            appendRow('Login Test', data.success, 'Returns user id: ' + );

    tests['inbox_messages'] = new Test( 
    function() {
        function(data) {
            appendRow('Inbox Messages', data.success, 'Returns: ' + );

    tests['logout'] = new Test( 
    function() {
            function(data) {
                appendRow('Logout Test', data.success, 'Returns nothing');
    function appendRow(row_name, status, return_val) {
        $('tbody').append('<tr><td>' + row_name + '</td><td>' + status + '</td><td>' + return_val + '</td></tr>')
// Botton to get the party started
    $('#clicky').click(function() {
            var tr = new TestRunner()

            // loop through test cases and add them to the TestRunner
            for (t in tests) {


Add in some HTML and you're set

            <td>Test Desc.</td>
<button id='clicky'>clicky</button>

Maybe a little CSS

    .main {
        width: 800px;
        margin: 0 auto;
        padding-top: 50px;
    .main table {
        width: 100%;
    .main table tbody tr {
        padding: 2px;
        border-top: 2px;