protractor: onPrepare for different test suites

﹥>﹥吖頭↗ 提交于 2019-12-10 04:29:19

问题


I have onPrepare in my conf.js file where I log in to the application. My understanding is every time I run 1 or more test suites, it first executes whatever is in onPrepare. This is great, as I use onPrepare to log into the application before running the tests.

Issue is, I don't want to login when I run my login-spec.js suite.

I could first logout before running through login-spec.js, but there must be a more elegant way to do this.


回答1:


As far as I understand, you need a place for suite-specific preparations.

This is what jasmine can help you with.

For jasmine 2.1 and above, there are built-in beforeAll and afterAll notations:

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.

If you are on an older jasmine version, use a separate jasmine-beforeAll package.



来源:https://stackoverflow.com/questions/27833429/protractor-onprepare-for-different-test-suites

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!