-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
cucumber.js
43 lines (38 loc) · 1.8 KB
/
cucumber.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var Cucumber = function(featuresSource, supportCodeDefinition) {
var listeners = Cucumber.Type.Collection();
var self = {
start: function start(callback) {
if (typeof(callback) !== 'function')
throw new Error(Cucumber.START_MISSING_CALLBACK_ERROR);
var features = self.parseFeaturesSource(featuresSource);
var supportCodeLibrary = self.initializeSupportCode(supportCodeDefinition);
self.executeFeaturesAgainstSupportCodeLibrary(features, supportCodeLibrary, callback);
},
attachListener: function attachListener(listener) {
listeners.add(listener);
},
parseFeaturesSource: function parseFeaturesSource(featuresSource) {
var parser = Cucumber.Parser(featuresSource);
return parser.parse();
},
initializeSupportCode: function initializeSupportCode(supportCodeDefinition) {
var supportCodeLibrary = Cucumber.SupportCode.Library(supportCodeDefinition);
return supportCodeLibrary;
},
executeFeaturesAgainstSupportCodeLibrary: function executeFeaturesAgainstSupportCodeLibrary(features, supportCodeLibrary, callback) {
var treeWalker = Cucumber.Ast.TreeWalker(features, supportCodeLibrary, listeners);
treeWalker.walk(callback);
}
};
return self;
};
Cucumber.START_MISSING_CALLBACK_ERROR = "Cucumber.start() expects a callback.";
Cucumber.Parser = require('./cucumber/parser');
Cucumber.Ast = require('./cucumber/ast');
Cucumber.SupportCode = require('./cucumber/support_code');
Cucumber.Runtime = require('./cucumber/runtime');
Cucumber.Listener = require('./cucumber/listener');
Cucumber.Type = require('./cucumber/type');
Cucumber.Util = require('./cucumber/util');
Cucumber.Debug = require('./cucumber/debug'); // Untested namespace
module.exports = Cucumber;