js-unit
Version:
A javascript unit testing tool inspired by the famous PHPUnit framework. This tool uses jasmine internally to run the tests
31 lines (27 loc) • 857 B
JavaScript
const babel = require('babel-core');
const defaultConfig = {
exclude : [/node_modules\/(?!js-unit)/],
presets : [
['env', {
targets : {
node : 'current'
}
}]
],
sourceMaps : true
};
let globalConfig = Object.assign({}, defaultConfig);
module.exports = function({content, filename}){
for (let x = 0, l = globalConfig.exclude.length; x < l; x++){
if (filename.match(globalConfig.exclude[x])){
return;
}
}
let config = Object.assign({ filename, sourceFileName : filename }, globalConfig);
delete config.exclude;
let result = babel.transform(content, config);
return { content : result.code, sourceMap : result.map };
};
module.exports.configure = function (options) {
globalConfig = Object.assign({}, defaultConfig, options);
};