javascript 使用 Nightwatch.js 与 Protractor 有什么区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27301676/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 07:18:17  来源:igfitidea点击:

What are the differences between using Nightwatch.js vs Protractor

javascriptangularjstestingprotractornightwatch.js

提问by Atav32

What are the differences? What are the advantages of using one over the other for an Angular project?

有什么区别?在 Angular 项目中使用一个比另一个有什么优势?

Nightwatch.jsvs Protractor

Nightwatch.js量角器

采纳答案by alecxe

If you are working on an AngularJS project, the choice is simple - Protractor:

如果您正在处理 AngularJS 项目,那么选择很简单 - Protractor

  • it is being made specifically for angular apps(though it can be used for non-angular apps also)
    • supports angular-specific locator strategies (like by.model, by.repeateretc)
    • waits for angular to start up during the page load (sync)
  • it is being actively maintainedand improved mostly by google developers with a close cooperation with an angular team - this means that protractor follows the angular release cycle and new changes
  • 它是专门为 angular 应用程序制作的(尽管它也可以用于非 angular 应用程序)
    • 支持特定于角度的定位器策略(例如by.modelby.repeater等)
    • 在页面加载(同步)期间等待 angular 启动
  • 它主要由谷歌开发人员与 angular 团队密切合作积极维护和改进 - 这意味着量角器遵循 angular 发布周期和新变化

回答by Kevin S

There are a few more differences that weren't laid out in the top answer.

还有一些差异没有在最佳答案中列出。

The big one for me is, as of now, protractor doesn't support phantomJS (http://www.protractortest.org/#/browser-setup#setting-up-phantomjs). I planned on integrating automation in to the CI system, but with protractor I would have to set up a windows VM to run the tests.

对我来说最重要的是,截至目前,量角器不支持 phantomJS ( http://www.protractortest.org/#/browser-setup#setting-up-phantomjs)。我计划将自动化集成到 CI 系统中,但是使用量角器我必须设置一个 Windows VM 来运行测试。

Other benefits of nightwatch:

守夜人的其他好处:

  • Asserts are done automatically.
  • Clean console output, you could hand off to anyone.
  • Test reports are automatically generated and saved to a /reportsdirectory.
  • 断言是自动完成的。
  • 干净的控制台输出,你可以交给任何人。
  • 测试报告会自动生成并保存到一个/reports目录中。

Protractor pros:

量角器优点:

  • The angular-specific locators that protractor supports is very powerful and could help immensely with creating stable tests.
  • WaitForAngular is also very helpful.
  • 量角器支持的特定于角度的定位器非常强大,可以极大地帮助创建稳定的测试。
  • WaitForAngular 也很有帮助。

EDIT: Since the time I wrote this comment and present day our team has happily switched over to using cypress.io. If you are deciding test frameworks I highly recommend checking it out: https://www.cypress.io/

编辑:从我写这篇评论到现在,我们的团队很高兴地转而使用 cypress.io。如果您正在决定测试框架,我强烈建议您查看:https: //www.cypress.io/