Code Monkey home page Code Monkey logo

mocha-fixture-dir's Introduction

mocha-fixture-dir Build status

Create/copy directories to automatically cleaned up temporary directories via Mocha

More information on the repository can be found in fixture-dir's documentation.

Getting Started

Install the module with: npm install mocha-fixture-dir

// Generate our fixture utils
var exec = require('child_process').exec;
var FixtureDir = require('fixture-dir');
var mochaFixtureDir = require('mochaFixtureDir');
var fixtureUtils = mochaFixtureDir(FixtureDir);

// Generate a tmp namespace for our tests
fixtureUtils.init('my-node-module-tests');

// Copy over folder contents (`git-log`) to temporary directory (`/tmp/my-node-module-tests/git-log`)
// This also cleans up the directory on `after`
fixtureUtils.mkdir({
  folderName: 'git-log',
  copyFrom: __dirname + '/test-files/git-log' // Folder with `.git` activity
});
before(function (done) {
  // Run `git log` in our directory ()
  exec('git log', {cwd: this.dir.path}, function (err, stdout, stderr) {
    // Save our stdout and callback
    this.stdout = stdout;
    done(err);
  });
});

it('retrieved `git log` in our fixture directory', function () {
  assert(this.stdout);
});

Documentation

mocha-fixture-dir returns mochaFixtureDir as its module.exports.

mochaFixtureDir(FixtureDir)

Factory that wraps a FixtureDir instance with Mocha methods.

Returns:

  • fixtureUtils FixtureUtils, object with methods for creating/interacting with a FixtureDir in Mocha's before/after contexts

FixtureUtils

FixtureUtils#init(folderName)

Initialize the FixtureDir constructor inside of a before block. This must be run before any other FixtureUtils calls.

FixtureUtils#mkdir(options)

Runs FixtureDir#mkdir on the current FixtureDir instance inside a Mocha's before block. Additionally, it cleans up the directory via FixtureDir#destroy in an after block.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via grunt and test via npm test.

Donating

Support this project and others by twolfson via gittip.

Support via Gittip

Unlicense

As of Apr 13 2014, Todd Wolfson has released this repository and its contents to the public domain.

It has been released under the UNLICENSE.

mocha-fixture-dir's People

Contributors

twolfson avatar

Stargazers

Rodrigo Ramírez Norambuena avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.