Skip to content
victorjonsson edited this page Feb 12, 2013 · 8 revisions

Example of tests written for a locally installed wordpress application. Preferably you install a jquery node module and will get pretty easy to determine which HTML elements that is present in each test.

config.json

{
  "host" : "localhost",
  "path" : "/my-wp-website/"
  "verbose" : false,
  "testdir" : "tests"
}

tests/test.djs

var dokimon = require('dokimon'),
    assert = require('assert'),
    wpUserName = 'John',
    wpPassword = '...';

module.exports = [

    new dokimon.TestFormPost(
        'Login',
        {
            url: 'wp-login.php?loggedout=true',
            keepCookies : true,
            write : {
                log : wpUserName,
                pwd : wpPassword,
                testcookie : '1'
            }
        },
        function(response, body) {
            assert.ok(body.indexOf('Howdy, '+wpUserName) > -1, 'Did not seem to be able to log in');
        },
        true
    ),

    new dokimon.Test(
        'MyAdminPageExists',
        {
            url : 'wp-admin/',
            keepCookies: true,
            dependsOn : 'Login'
        },
        function(res, body) {
           var pluginURL = 'options-general.php?page=my-plugin/my-plugin-admin-page.php';
           assert.ok( body.indexOf("<a href='"+pluginURL) > -1, 'My admin page does not exist in wp-admin navigation');
        }
    )
];
Clone this wiki locally