While looking through the code in the protractor-jasmine2-screenshot-reporter npm package I noticed that it contains a beforeLaunch function, which is exported with the rest of the functions.
I know that the lifecycle stages run in the following order so my question is: How can this reporter ever possibly affect the beforeLaunch stage of the execution when the jasmine object itself isn't available until the onPrepare stage?
--- beforeLaunch
--- onPrepare (set in conf) ***reporters initialized here
--- jasmineStarted (set in reporter)
--- beforeAll
--- suiteStarted (set in reporter)
--- specStarted (set in reporter)
--- beforeEach (set in testFile)
+++ afterEach (set in testFile)
+++ specDone (set in reporter)
+++ suiteDone (set in reporter)
+++ afterAll
+++ jasmineDone (set in reporter)
+++ onComplete (set in conf)
+++ afterLaunch
Code from protractor-jasmine2-screenshot-reporter
function Jasmine2ScreenShotReporter(opts) {
this.beforeLaunch = function (callback) {
};
this.afterLaunch = function (callback) {
};
this.jasmineStarted = function (suiteInfo) {
};
this.suiteStarted = function (suite) {
};
this.suiteDone = function (suite) {
};
this.specStarted = function (spec) {
};
this.specDone = function (spec) {
};
this.jasmineDone = function () {
};
return this;
}
I possible I have fundamentally misunderstood some behavior here but hope someone can shed some light on this for me.
Protractor uses extra plugin hooks and resolves these in addition to the Jasmine hooks. These are usually resolved in Protractor's runner. You can read up on the plugins here: https://github.com/angular/protractor/blob/master/lib/plugins.ts#L25
So for example, onPrepare
plugin is checked in the config (https://github.com/angular/protractor/blob/selenium4/lib/runner.ts#L63) and executed by the runner (https://github.com/angular/protractor/blob/selenium4/lib/runner.ts#L82). These two files referencing the runner is for the selenium 4 upgrade branch. It is easier to look at these versions since they do not have a chain of thenable promises.