在查看 protractor-jasmine2-screenshot-reporter npm 包中的代码时,我注意到它包含一个 beforeLaunch 函数,该函数与其余函数一起导出。
我知道生命周期阶段按以下顺序运行,所以我的问题是:当 jasmine 对象本身在 onPrepare 阶段之前不可用时,这个记者怎么可能影响执行的 beforeLaunch 阶段?
--- 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
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;
}
我可能从根本上误解了这里的一些行为,但希望有人能为我阐明这一点。