var cucumber = function(options) { var runOptions = []; // load support files and step_definitions from options var files = []; if (options.support) { files.concat(glob([].concat(options.support))); } if (options.steps) { files.concat(glob([].concat(options.steps))); } files.forEach(function(file) { runOptions.push('-r'); runOptions.push(file); }); runOptions.push('-f'); var format = options.format || 'pretty'; runOptions.push(format); var run = function(argument, callback) { var filename = argument.path; if (filename.indexOf(".feature") === -1) { return callback(); } var processOptions = runOptions.slice(0); processOptions.push(filename); var cli = spawn(binPath, processOptions); var output = []; cli.stdout.on('data', function(data) { output.push(data); }); cli.on('exit', function(exitCode) { var data = Buffer.concat(output).toString(); process.stdout.write(data); process.stdout.write('\r\nFeature: ' + filename + '\r\n'); }); return callback(); }; return es.map(run); };
function getScripts(moduleName) { if (config.get("assets.min")) { return ["js/" + moduleName + ".js"]; } else { var scripts = []; try { var files = require("../../client/js/" + moduleName + ".json"); scripts = glob({cwd: "app/client/"}, files); } catch (e) { } return scripts; } }
gulp.task('before-tests-index', function() { // NOTE: `expandFiles` expects files to be present at the given location // on the file system (uses "file exists" test), else it will return // nothing for each file "not found" var testFiles = expandFiles(testem.serve_files); testFiles = _.map(testFiles, function(file) { return file.replace('tmp/test/', ''); }); return gulp.src('test/index.html') .pipe(template({ files: testFiles })) .pipe(gulp.dest('tmp/test')); });
getFileList: function(fileglob) { var self = this, jsonfile, destFiles = [], srcFiles = [], package_path, matches = Glob(fileglob); return new Promise(function(resolve, reject) { if(!matches.length) return reject('No files matching'); matches.forEach(function(file) { var internalFileName = path.normalize(file); if (internalFileName.match('package.json')) { jsonfile = self.closerPathDepth(internalFileName, jsonfile); package_path = path.normalize(jsonfile.split('package.json')[0] || './'); } if(!fs.lstatSync(internalFileName).isDirectory()) { srcFiles.push(internalFileName); } }); if (!jsonfile) { return reject('Could not find a package.json in your src folder'); } srcFiles.forEach(function(file) { destFiles.push({ src: file, dest: file.replace(package_path, '') }); }); resolve({ files: destFiles, json: jsonfile }); }); },
module.exports = function (options) { var argv = ['node', 'cucumber-js']; var format = options.format || 'pretty'; var tags = []; var files = []; var runOptions = ['-f', format]; var stepRegex = options.stepRegex || '^($1)[^-_]'; var stepRegexFlags = options.stepRegexFlags || 'gi'; if (options.support) { files = files.concat(glob([].concat(options.support))); } if (options.steps) { files = files.concat(glob([].concat(options.steps))); } // Support tags in array or string format // @see https://github.com/cucumber/cucumber/wiki/Tags if (options.tags) { tags = ['--tags', options.tags]; if (_.isArray(options.tags)) { if (options.requireAllTags) { tags = _(options.tags) .map(function (tag) { return ['--tags', tag] }) .flatten() .value(); } else { tags = ['--tags', options.tags.join(',')]; } } } var parseAndRunTests = function(file, enc, callback) { var feature = path.parse(file.path); if (feature.ext !== '.feature') { return callback(); } var index = _.findIndex(files, function (step) { var parsedStepPath = path.parse(step); // Match step name with feature name, stop searching when we hit - or _ // after first part match. In case we are looking for ux-list and we // come across ux-list-item. var regex = new RegExp(stepRegex.replace('$1', feature.name), stepRegexFlags); return parsedStepPath.name.match(regex); }); var matchingStep = files[index]; var args = argv.concat(['-r', matchingStep, file.path], runOptions, tags); Cucumber.Cli(args).run(function(succeeded) { if (succeeded) { callback(); } else { callback(new Error('Cucumber tests failed!')); } }); }; var finish = function (callback) { this.emit('end'); return callback(); }; return through.obj(parseAndRunTests, finish); };