How can I run Nightwatch tests in a specific order?

匿名 (未验证) 提交于 2019-12-03 08:42:37

问题:

I have several tests which test the UI and also serve to create data along the way.

A separate set of tests rely on this data, meaning that these must run only after the first set have run.

I know about running a group of them, or running them with tags, but how can I run them in a specific order?

回答1:

Nightwatch will run each test within a particular file in order, so one (naive) solution would be to put every test in the same file, in the order you want them to run.

This will get unwieldy if you have too many tests for a single file. To get around this, you can take advantage of Nightwatch running each test file in alphabetical order. One way to do this would be to prefix each test file with a number indicating the order you want them to be run in. For example, if you had two test files, before.js and after.js, and you wanted before.js to run first, you could just change the names of the files to 01before.js and 02after.js. This will make Nightwatch read the files in the order you want.



回答2:

This isn't a great answer but it works: numerically sequence your test files.

0001_first_test_I_want_to_run.js 0002_second_test_I_want_to_run.js ... 9999_last_test_I-want_to_run.js 


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