How to make onPrepare wait beforeLaunch to finish
Hi, I use protractor to test big client application, before the tests run I use REST API to configure the server. I would like to use beforeLaunch for server configuration and some parameters initialization (that I need both for client and server) and then make some preparations on the client in onPrepare. The problem is it seems like onPrepare doesn't wait for the beforeLaunch to finish (in onPrepare I can't access parameters initialized in beforeLaunch). How can I make it wait? Thank you
Have beforeLaunch return a promise when you are done with your setup. onPrepare will not start until it is resolved.
Example:
beforeLaunch: function() {
var q = require('q');
var deferred = q.defer();
// Do some things
doAllTheThings().then(function(){
deferred.resolve();
});
return deferred.promise;
},
Closing as an answered question.
Thank you, but it still doesn't work :( Also, several things I do in beforeLaunch() are not async.
It sounds like you probably have some sort of variable scoping issues then.