Commit dd06abf0 authored by Tom Jorquera's avatar Tom Jorquera
Browse files

runner: replace parallel loading of resources with sequential one

The runner would load all the client resource files in parallel, causing errors
intermittently due to some resources depending on other ones.
This behavior was incorrect.

Runner to uses `resolveSequentially` that ensure that each resource is loaded in
order.
parent 857d28df
const webdriverio = require('webdriverio');
// Utility function to resolve a list of promise-based function calls
// on a given element list sequentially
function resolveSequentially(f, elements) {
return elements.reduce(
(acc, curr) => acc.then(() => f(curr)).catch(err => console.error(err)),
new Promise(resolve => resolve()));
}
module.exports = config => ({
run: (controllerFilesList, server, room, clientConfig) => {
const client = webdriverio.remote(config.driver);
return client.init()
.url(server + '/' + room)
.then(
() => Promise.all(controllerFilesList.map(
f => client.execute(f, room, clientConfig))))
.then(() => resolveSequentially(f => client.execute(f, room, clientConfig),
controllerFilesList))
.then(() => client.execute(() => {
/* eslint-disable no-undef */
robot.start();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment