skutter
Version:
Skutter: Opinionated BDD Browser based test framework
70 lines (69 loc) • 2.75 kB
JavaScript
;
const Yadda = require("yadda");
const process_error_sender_1 = require("../services/process-error-sender");
const jasmine_result_listener_1 = require("./jasmine-result-listener");
const execution_broadcaster_1 = require("./execution-broadcaster");
const executor_1 = require("./executor");
const required_library_provider_1 = require("../services/required-library-provider");
const screenshotter_1 = require("../services/screenshotter");
let executorConfig = global.skutterConfig;
let executionBroadcaster = new execution_broadcaster_1.ExecutionBroadcaster();
let jasmineListener = new jasmine_result_listener_1.JasmineResultListener(executionBroadcaster);
let requiredLibrariesProvider = new required_library_provider_1.RequiredLibraryProvider(executorConfig.libraryPaths);
let screenshotter = new screenshotter_1.Screenshotter(executorConfig.basePath);
function teardownOnError() {
if (browser) {
browser.close();
browser.quit();
}
setTimeout(() => {
process.exit(-1);
}, 100);
}
try {
Yadda.plugins.jasmine.StepLevelPlugin.init();
}
catch (stepLevelPluginInitExeception) {
process_error_sender_1.ProcessErrorSender.send("protractor-bootstrap", "Error during Yadda->StepLevelPlugin initialisation.", stepLevelPluginInitExeception.message)
.then(() => {
teardownOnError();
});
}
try {
jasmine.getEnv().addReporter(jasmineListener);
}
catch (jasmineReporterAddException) {
process_error_sender_1.ProcessErrorSender.send("protractor-bootstrap", "Error during Jasmine->addReporter.", jasmineReporterAddException.message)
.then(() => {
teardownOnError();
});
}
let executor = null;
try {
executor = new executor_1.Executor(requiredLibrariesProvider, executionBroadcaster, screenshotter, jasmineListener, executorConfig.basePath);
}
catch (executorCreationException) {
process_error_sender_1.ProcessErrorSender.send("protractor-bootstrap", "Error during Executor creation.", executorCreationException.message)
.then(() => {
teardownOnError();
});
}
try {
let nextFeature = executorConfig.features.shift();
while (nextFeature) {
executor.execute(nextFeature, browser)
.catch((error) => {
process_error_sender_1.ProcessErrorSender.send("protractor-bootstrap", "Error during execution.", error)
.then(() => {
teardownOnError();
});
});
nextFeature = executorConfig.features.shift();
}
}
catch (executionException) {
process_error_sender_1.ProcessErrorSender.send("protractor-bootstrap", "General Error during execution.", executionException.message)
.then(() => {
teardownOnError();
});
}