Skip to content

Instantly share code, notes, and snippets.

@scharf
Created April 2, 2015 14:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scharf/b0ce919d558b8cc82222 to your computer and use it in GitHub Desktop.
Save scharf/b0ce919d558b8cc82222 to your computer and use it in GitHub Desktop.
require all tests
'use strict';
// to get intellij navigation correctly, we need
// static imports. Therefore we dynamically create
// a test file that imports all tests we want to run...
var globule = require('globule');
var path = require('path');
var fs = require('fs');
// write a temp module with all tests
function writeTestFile(file) {
// find a .ntest.js files
var paths = globule.find(
'app/**/*.ntest.js',
'!**node_modules/**',
{
cwd: path.resolve(__dirname, '..')
}
);
// lets create the require statements for each test file
var data = paths.map(function(singlePath){
return "require('" + singlePath + "');\n";
}).join('');
// save it
var fd = fs.openSync(path.resolve(__dirname, file), 'w');
fs.writeSync(fd, data);
fs.closeSync(fd);
}
// we create a test file with all the tests we want to run
writeTestFile('app-ntest.tmp.js');
require('./app-ntest.tmp.js');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment