Да, смотрите этот адрес: http://webdriver.io/guide/testrunner/gettingstarted.html
если вы запускаете wdio конфигурации, будет генерировать файл с именем wdio.conf.js, на этот файл существует функцию для запуска сценариев до или после испытаний, я показать пример функций содержит этот файл:
// =====
// Hooks
// =====
// Run functions before or after the test. If one of them returns with a promise, WebdriverIO
// will wait until that promise got resolved to continue.
//
// Gets executed before all workers get launched.
onPrepare: function() {
// do something
},
//
// Gets executed before test execution begins. At this point you will have access to all global
// variables like `browser`. It is the perfect place to define custom commands.
before: function() {
// do something
},
//
// Gets executed after all tests are done. You still have access to all global variables from
// the test.
after: function(failures, pid) {
// do something
},
//
// Gets executed after all workers got shut down and the process is about to exit. It is not
// possible to defer the end of the process using a promise.
onComplete: function() {
// do something
}
очень важно, если вы запускаете асинхронный скрипт, и вы будете ждать обратного вызова в момент очистить базу данных, так что вам нужно обещание, иначе следующий шаг крюк запустит не дожидаясь предыдущего крючка функции, например:
onPrepare: function() {
return new Promise(function(resolve, reject) {
sauceConnectLauncher({
username: 'the_pianist2',
accessKey: '67224e83a-1cf7440d-8c88-857c4d3cde49',
}, function (err, sauceConnectProcess) {
if (err) {
return reject(err);
}
console.log('success');
resolve();
});
});
},
Чтобы начать соединение соуса, я бы рекомендовал использовать услугу соуса http://webdriver.io/guide/services/sauce.html, что делает его более удобным – ChristianB