npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dokimon

v0.1.6

Published

This is a module used for setting up automated tests of various kinds. It may also be used as an alternative (or complement) to browser test tools such as Selenium. Write tests for a website or web service and manage them with a command line interface. Do

Downloads

26

Readme

build status

Dokimon

This node module is used to create automated acceptance tests. It's also a great alternative (or complement) to client test tools such as Selenium. You write your tests in a heartbeat and run them using the command line.

Example usages:

  • Verify that your online services is up and running
  • Verify that your RESTful API is responding and behaving as expected
  • Validate that your website generates the expected html code

Getting started

1) Install node and npm

Take a look at http://nodejs.org if you don't already have node and npm installed since before

2) Create project directory and install dokimon

Create a directory where you find suitable, go to the directory in your shell interpreter and run npm install -g dokimon

4) Create test directory

You write your tests in files that has the extension .djs (more information about writing the tests below).

3) config.json

This file should be placed in the root of your project directory and contain a JSON file with the properties "host", "verbose" and "testdir".

  • host (String) — Specifies against which host you're going to run the tests.
  • verbose (Boolean) — Makes it possible to get a more verbose output when running the tests
  • testdir (String) — Relative path to the directory where you have your test scripts. This directory should be placed in the project directory.

It's possible to change all of these parameters on the fly when using the command line interface. It's also possible to completely switch to another configuration file when using the command line interface. Dokimon will search for a file named config.json in the current working directory if not specified when running the tests.

Example config.json

{
  "host" : "api.myservice.com",
  "verbose" : false,
  "testdir" : "tests",
  "path" : ""
}

Example project layout

/Users/john/nodetests/
    tests/
      - myscript.djs
    - config.json

Writing tests

You can have one or several script files in your test directory, each containing one or several tests. All script files in the test directory should have the extension .djs. The script files is ordinary node modules (http://howtonode.org/creating-custom-modules).

Basic example (myscript.djs)

var dokimon = require('dokimon'),
    assert = require('assert');

var checkHomepage = new dokimon.Test(
  'HomePageIsRunning', 
  {url : '/'}, 
  function(res, body) {
    assert.equal(res.statusCode, 200, 'My website is not responding');
  }
);
      
module.exports = checkHomepage;

You can also export an array with tests.

var dokimon = require('dokimon'),
    assert = require('assert');

var checkHomepage = new dokimon.Test(
  'HomePageIsRunning'...
);

var checkSiteSearch = new dokimon.TestPostForm(
  'SearchIsWorking', 
  {
    url : '/search/',
    write : {s : 'hockey', sortby : 'date', sortorder : 'desc'}
  },
  function(res, body) {
    assert.equal(res.statusCode, 200, 'Search is down');
    // and some other assertions that validates expected search result
  }
);
  
module.exports = [checkHomepage,checkSiteSearch];

Assuming that I've written this code in a file located in my test directory (defined in config.json) and that the file has .djs as extension I can now run my tests by calling dokimon -r in the project directory. I can also choose to only run one of the tests by calling dokimon -rs myscript HomePageIsRunning

Read more about writing tests here

Example, tests for a RESTful API

Example, tests for wordpress

CLI

dokimon -r

Run all dokimon scripts in the test directory defined in config.json

dokimon -r api website

Run the scripts named api.djs and website.djs located in the test directory defined in config.json. You can also write the paths to the scripts, -r tests/api.djs tests/website.djs

dokimon -rs website HomePageIsRunning

Run the test named HomePageIsRunning that's located in the script website.djs located in the test directory defined in config.json

dokimon -l

List all scripts (and their tests) that is located in the test directory, defined in config.json

dokimon -s website

List all available tests in the script website.djs

Optional arguments

-verbose - Gives you a more verbose output when running the tests

-config /Users/john/dokimon/production.json - Use another config file than the one that is automatically loaded by dokimon

-host stage.myservice.com - Override the host defined in config.json

-testdir /var/nodetests/ - Use another test directory than the one defined in config.json