npm 包怎么可能影响 Protractor 执行的 beforeLaunch 阶段?
How can a npm package ever possibly affect the beforeLaunch stage of the execution for Protractor?
在查看 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;
}
我可能从根本上误解了这里的某些行为,但希望有人能为我阐明这一点。
除了 Jasmine 挂钩之外,Protractor 使用额外的插件挂钩并解决这些问题。这些通常在 Protractor 的 runner 中解决。您可以在此处阅读有关插件的信息:https://github.com/angular/protractor/blob/master/lib/plugins.ts#L25
因此,例如,onPrepare
插件已在配置中选中 (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)。这两个引用运行器的文件用于 selenium 4 升级分支。查看这些版本更容易,因为它们没有可用的承诺链。
在查看 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;
}
我可能从根本上误解了这里的某些行为,但希望有人能为我阐明这一点。
除了 Jasmine 挂钩之外,Protractor 使用额外的插件挂钩并解决这些问题。这些通常在 Protractor 的 runner 中解决。您可以在此处阅读有关插件的信息:https://github.com/angular/protractor/blob/master/lib/plugins.ts#L25
因此,例如,onPrepare
插件已在配置中选中 (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)。这两个引用运行器的文件用于 selenium 4 升级分支。查看这些版本更容易,因为它们没有可用的承诺链。