I need to request some json files that contain data I use for testing. I would like to make the request in the setup method, but there is no async method attached to it. When I run the code below, the log inside the test login function gets sent to the console before my logs from the setup method get sent. Is there a way I can tell setup to wait till my calls get completed before running the tests?
define([
'intern!object',
'pages/LoginPage',
'data-objects/DataFetcher'
], function(registerSuite, LoginPage, DataFetcher) {
registerSuite(function() {
var loginId = admin;
var password = test;
var regionData = US;
var loginPage = null;
return {
name: 'Login test',
setup: function() {
// Initialize page objects
loginPage = new LoginPage(this.remote, this.timeout);
// get test data
DataFetcher.getData(Pages.LoginPage).then(function(response) {
logger.info(DataFetcher.generateData(response));
});
DataFetcher.getData(Pages.TablePage).then(function(response) {
logger.info(DataFetcher.generateData(response));
});
DataFetcher.getData(Pages.PersonPage).then(function(response) {
logger.info(DataFetcher.generateData(response));
});
DataFetcher.getData(Pages.BasicInfoPage).then(function(response) {
logger.info(DataFetcher.generateData(response));
});
DataFetcher.getData(Pages.CompanyInfoPage).then(function(response) {
logger.info(DataFetcher.generateData(response));
});
},
login: function() {
logger.log('info', 'Login is ' + loginId + ' Password ' +
password);
return loginPage.load(regionData.BASE_URL)
.login(loginId, password)
.getAccumulatedState();
}
};
});
});
Aucun commentaire:
Enregistrer un commentaire