量角器:onPrepare 用于不同的测试套件

protractor: onPrepare for different test suites

我在登录应用程序的 conf.js 文件中有 onPrepare。我的理解是每次运行 1 个或多个测试套件时,它首先执行 onPrepare 中的任何内容。这很棒,因为我在运行测试之前使用 onPrepare 登录应用程序。

问题是,我不想在运行 login-spec.js 套件时登录。

我可以在运行 login-spec.js 之前先注销,但必须有更优雅的方法来做到这一点。

据我了解,您需要一个特定套件准备的地方。

这就是 jasmine 可以帮助您的。

对于 jasmine 2.1 及更高版本,有内置的 beforeAll and afterAll 符号:

The beforeAll function is called only once before all the specs in describe are run, and the afterAll function is called after all specs finish. These functions can be used to speed up test suites with expensive setup and teardown.

如果您使用的是旧 jasmine 版本,请使用单独的 jasmine-beforeAll package