isolated

isolated provides one-time folders for unit tests.

isolated

isolated provides one-time folders for unit tests.

$ npm install isolated

Using isolated is easy. All you need to do is to add a reference to it within your Node.js application:

var isolated = require('isolated');

Then you can use it within your tests. In its simplest form, isolated provides a one-time folder for your test and guarantees to clean up later.

test('...', function (done) {
  isolated(function (errdirectory) {
    // ... 
  });
});

Additionally, you may want to specify a file or a directory that isolated shall copy to the one-time directory before running your test.

test('...', function (done) {
  isolated({
    files: 'foo.txt'
  }, function (errdirectory) {
    // ... 
  });
});

If you need to copy multiple files or directories, specify an array instead of a single item.

test('...', function (done) {
  isolated({
    files: [ 'foo.txt', 'bar.txt' ]
  }, function (errdirectory) {
    // ... 
  });
});

Sometimes you may want isolate to preserve the sourcestimestamps. For that additionally provide thepreserveTimestampsoption and set it totrue`.

test('...', function (done) {
  isolated({
    files: [ 'foo.txt', 'bar.txt' ],
    preserveTimestamps: true
  }, function (errdirectory) {
    // ... 
  });
});

This module can be built using Grunt. Besides running the tests, this also analyses the code. To run Grunt, go to the folder where you have installed isolated and run grunt. You need to have grunt-cli installed.

$ grunt

The MIT License (MIT) Copyright (c) 2013-2015 the native web.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.