<commit_before>var parser  = require('../utils/feature-parser'),
    session = require('moonraker').session,
    config  = require('moonraker').config,
    Yadda   = require('yadda'),
    glob    = require('glob'),
    chai    = require('chai');

require('coffee-script/register');

var language = parser.getLanguage(config.language);

Yadda.plugins.mocha.StepLevelPlugin.init({ language: language });
chai.should();

features(session.queue, function (feature) {

  scenarios(feature.scenarios, function (scenario) {

    steps(scenario.steps, function (step, done) {
      if (step === scenario.steps[0]) session.reset();
      session.execute(function () {
        new Yadda.Yadda(loadStepDefs(language)).yadda(step);
      }).then(done);
    });

  });
});

function loadStepDefs(language) {
  var dictionary = new Yadda.Dictionary();
  var library = new language.library(dictionary);

  glob.sync(config.stepsDir + "/**/*").forEach(function (file) {
    var steps = require('../../../../' + file);
    try {
      steps.define(library);
    } catch (e) {
      if (e instanceof TypeError) {
        console.warn("*** File: "+ file + " contained no step definitions\n");
      }
    }
  });
  return library;<commit_msg>Lookup steps definitions in javascript files only<commit_after>var parser  = require('../utils/feature-parser'),
    session = require('moonraker').session,
    config  = require('moonraker').config,
    Yadda   = require('yadda'),
    glob    = require('glob'),
    chai    = require('chai'),
    path    = require('path');

require('coffee-script/register');

var language = parser.getLanguage(config.language);

Yadda.plugins.mocha.StepLevelPlugin.init({ language: language });
chai.should();

features(session.queue, function (feature) {

  scenarios(feature.scenarios, function (scenario) {

    steps(scenario.steps, function (step, done) {
      if (step === scenario.steps[0]) session.reset();
      session.execute(function () {
        new Yadda.Yadda(loadStepDefs(language)).yadda(step);
      }).then(done);
    });

  });
});

function loadStepDefs(language) {
  var dictionary = new Yadda.Dictionary();
  var library = new language.library(dictionary);
  var currentDirectory = path.dirname(process.argv[1]);

  glob.sync(config.stepsDir + "/**/*.js").forEach(function (file) {
    var steps = require(path.join(currentDirectory, '../../../../', file));
    try {
      steps.define(library);
    } catch (e) {
      if (e instanceof TypeError) {
        console.warn("*** File: "+ file + " contained no step definitions\n");
      }
    }
  });
  return library;
{'fraction_non_alphanumeric': 0.1726923076923077, 'fraction_numerical': 0.001153846153846154, 'mean_word_length': 3.401015228426396, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2079879', 'n_tokens_mistral': 808, 'n_tokens_neox': 795, 'n_words': 156}