Closed ghost closed 8 years ago
The yadda.js contains this code:
var Yadda = require("yadda");
Yadda.plugins.mocha.StepLevelPlugin.init();
var English = Yadda.localisation.English;
var path = Yadda.shims.path;
new Yadda.FeatureFileSearch("./features").each(function (file) {
featureFile(file, function (feature) {
var stepsFile = String("./" + path.dirname(file) + "/step_definitions/" + path.basename(file, ".feature")).split("\\").join("/");
var library = English.library();
var defineSteps = require(stepsFile);
defineSteps.call(library);
var yadda = Yadda.createInstance(library);
scenarios(feature.scenarios, function (scenario) {
steps(scenario.steps, function (step, done) {
yadda.run(step, done);
});
});
});
});
So the module path is generated in a callback. I think this is the problem because if I add the following to the beginning of the file, then the code works properly.
require("./features/step_definitions/noop");
require("./features/step_definitions/Class");
require("./features/step_definitions/UserError");
require("./features/step_definitions/CompositeError");
I am not sure why this is a problem or how to fix it.
According to this SO answer http://stackoverflow.com/a/27672458/607033 it is possible to add a glob like pattern if you want dynamic require in your code. So browserify will know which files to add to the bundle.
Let's hope someone can help you. I do not understand your setup and cannot :cry:.
Others had a similar issue: https://github.com/nikku/karma-browserify/issues/178
Yadda is a BDD testing lib which has feature files and step definition files. The yadda.js is looking for feature files and require-ing the step definition files, which have a similar path than the feature files. At least by the lib I am developing now. So it is not that complicated and only the require(stepsFile);
what you need to understand that the stepsFile
path is generated by the code, so it is not static. I am trying now to add the paths I need with require-globify and a glob pattern, but somehow it does not work. :S
I have an error message:
But according to the debug log, the file was served and bundled:
My
karma.conf.js
is in theD:/creation/software developer/projects/o3
directory, and it contains the following code:The deps are installed and the op system is windows 7 x64.
Any idea why I cannot load this module?