There are
ActionManager.js reads files (libraries) with all possible test functions from folder;
WorkflowManager.js reads files with descriptions of needed tests (test workflow). Each of file contains array of action and arguments.
TestsRunner.js requires and runs ActionManager and WorkflowManager. After that I want to run each test workflow's action (executes Jasmine test) with arguments.
How to make this process executed in serious?
I've tried to implement runner as:
call require before describe block, so Jasmine's tests run before this
put require into beforeEach, so beforeEach is called exactly before executing it(); so I know quantity of flows to loop it() just after requiring and getting array of flows; but when it() executes, it should be already called from already defined loop's iteration
I put mock describe block with it() for initializing under main describe, but in this case cycle for() get quantuity of flows as 0 and after this all describes starts to execute and quantity is initialized
I wrapped both decribe into one else -> code between decribe and it, describe and inner for cycle doesn't executed.
Here is the part of code with requiring just WorkflowManager and looping for workflows array size with the console output on every iteration.
var firstTime = true;
beforeEach(function() {
if (firstTime) {
var flow = protractor.promise.controlFlow();
flow.execute(function() {
console.log("I'm beforeach part#1");
path = require("path");
testsPath = path.resolve("./e2e/tests/");
//requiring WorkflowManager
wfMng = require('./utils/WorkflowManager.js');
}).then(function() {
console.log("I'm beforeeach part#2");
var workflowPath = path.resolve("./e2e/data/workflows/");
//getting array of worklows
wfs = wfMng.getAllWorkflows(workflowPath + '\\');
}).then(function() {
console.log("I'm beforeeach part#3");
//console output of length of workflows array = 1 - is correct
console.log("Length of array in before each after initing " + wfs.length); //LENGTH = 1
firstTime = false;
})
}
});
describe("Describe for initialization", function() {
it("It block for initialization", function() {
expect(0).toEqual(0);
console.log("Length in 1st describe: " + wfs.length); //LENGTH = 1
});
});
describe("Core describe", function() {
console.log("This console log doesn't executed!!!!");
//CYCLE ISN'T EXECUTED - LENGTH = 0
for (var workflowidx = 0, wlen = wfs.length; workflowidx < wlen; workflowidx += 1) {
(function(widx) {
console.log("Length in for cycle: " + wfs.length);
describe("SBB" + widx, function() {
console.log("This console log doesn't executed!!!!");
it("My test" + widx, function() {
expect(2).toEqual(2);
console.log("Length in it func: " + wfs.length); //LENGTH = 1
});
});
})(workflowidx);
};
});
How to processeed both require, getting arrays of possible actions and needed workflows, and just after this executing every action in the loop?
Should I use Jasmine's spy somehow?
Node.JS v0.10.30
Protractor v 1.0.0