wary

1.1.1 • Public • Published

wary

npm version dependencies Build Status Build status

Tiny unit test framework to test code with real files.

Motivation

Running tests that interact with real files has usually been a mess. Tipic solutions include mocking the filesystem module, which can reduce the effectiveness of your test code, or use modules that create a virtual filesystem in RAM.

Wary allows you to easily run test cases on real files, allowing you to increase your trust in the code, by taking the required files as inputs and copying them to a temporal location allowing the test to freely modify them, remove them, etc without harming the original file. The temporal files are later removed for you automatically.

Installation

Install wary by running:

$ npm install --save wary

Documentation

wary.it(name, files, action)

The files declared in the second argument are copied to a temporary location and then automatically removed, so you can freely interact with them within your tests.

Kind: static method of wary
Summary: Declare a unit test
Access: public

Param Type Description
name String test name
files Object files to use in the test
action function test action

Example

Promise = require('bluebird')
fs = Promise.promisifyAll(require('fs'))
wary = require('wary')
assert = require('assert')
 
wary.it 'should write to a file',
    text: 'path/to/text.txt'
, (files) ->
    fs.writeFileAsync(files.text, 'Hello World', encoding: 'utf8').then ->
        fs.readFileAsync(files.text, encoding: 'utf8').then (contents) ->
            assert.equal(contents, 'Hello World')

wary.run() ⇒ Promise

Kind: static method of wary
Summary: Run all tests
Access: public
Example

wary.run()

Support

If you're having any problem, please raise an issue on GitHub and I'll be happy to help.

Tests

Run the test suite by doing:

$ gulp test

Contribute

Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:

$ gulp lint

License

The project is licensed under the MIT license.

Package Sidebar

Install

npm i wary

Weekly Downloads

1

Version

1.1.1

License

MIT

Last publish

Collaborators

  • jviotti