Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

testutil

jprichardson1850.7.0

testutil contains methods to aid in automatic testing of your application.

test, testing, utility, tdd, bdd, unit

readme

Node.js - testutil

build status

This module provides methods to aid in testing your Node.js apps.

Installation

npm install --save-dev testutil

Make sure that you run the test script to verify that it works on your system.

Libraries included:

colors

It's already global. You don't need to do anything. It's nice to help debug some output as it modifies the string prototype.

shelljs

var shell = require('testutil').shelljs

Usage

var testutil = require('testutil')

Module Methods

createTestDir(app)

Synchronously creates a test directory and returns the path. Deletes the directory if it exists and recreates it.

var dirPath = testutil.createTestDir('myapp');

e.g. /tmp/test-myapp

fetchTestFiles(dirPath, callback)

Asynchronously fetches all of the files in a specified directory that end in .test.coffee or .test.js.

testutil.fetchTestFiles('test/', function(files) {
// do something with test files
});

You might use this in conjunction with Mocha.

md5(data)

Synchronously calculates the md5 of the data.

License

(The MIT License) See LICENSE for details.

Copyright (c) 2011-2013 JP Richardson

changelog

0.7.0 / 2013-10-29

  • refactored T(), F(), EQ(), NEQ() into terst
  • removed methods createbuffer(), createFileWithData

0.6.0 / 2013-08-19

  • added shelljs package

0.5.1 / 2013-04-30

  • added colors package

0.5.0 / 2013-03-18

  • dropped node v0.6 and added v0.10 support
  • removed exit() from global.
  • removed createTempDir()
  • removed generateTestPath()
  • upgrade to latest rimraf dep

0.4.0 / 2013-01-17

  • Removed TTrue, TFalse, TTRUE, TFALSE.
  • Added md5(data) method.
  • Added EQ and NEQ global methods.

0.3.0 / 2012-12-11

  • Removed CoffeeScript.
  • Upgraded fs-extra dep.

0.2.4 / 2012-09-18

  • Don't actually delete dir in createTestDir(), but delete the files.

0.2.3 / 2012-08-18

  • Added createTestDir method.

0.2.2 / 2012-08-11

  • Added generateTestPath method.

0.2.1 / 2012-08-03

  • Added global methods TTRUE, TTrue, TFALSE, TFalse as aliases for T/F.

0.2.0 / 2012-07-10

  • Removed fs-extra dependency. Removed TODO() global method.

0.1.1 / 2012-05-11

  • Added exit() method. (Just an alias for process.exit())

0.1.0 / 2012-02-26

  • Removed string dependency.
  • Added growl depenedency.

0.0.3 / 2012-02-03

  • Updated README
  • Added module method fetchTestFiles()
  • Added global methods: T(), F(), and TODO()
  • Switched from Make to Cake
  • Provide pure JS version now instead of requiring CoffeeScript
  • Moved *.coffee files from lib/ to src/.
  • Deleted index.coffee

0.0.2 / 2012-01-12

  • createFileWithData now returns the input filePath

0.0.1 / 2012-01-12

  • Initial release.