Created
April 2, 2015 14:35
-
-
Save scharf/b0ce919d558b8cc82222 to your computer and use it in GitHub Desktop.
require all tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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