用 jasmine 测试 javascript UI 的最佳方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12112320/
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-26 15:20:33  来源:igfitidea点击:

best approach for testing javascript UI with jasmine

javascriptseleniumtddjasmine

提问by opensas

I was having a first look at the jasmine framework and it looks really promising, but I couldn't find an easy way to work with the dom.

我第一次看 jasmine 框架,它看起来很有前途,但我找不到一种简单的方法来处理 dom。

I mean, simulating user interaction, like completing and input, clicking a button, and then checking that the dom is correctly updated, like showing errors after input validation, and showing the modified data. Just the kind of stuff you usually do with tools like selenium.

我的意思是,模拟用户交互,比如完成和输入,点击一个按钮,然后检查 dom 是否正确更新,比如在输入验证后显示错误,以及显示修改后的数据。就是您通常使用 selenium 之类的工具做的事情。

Is there a standard way to do it or is ui testing out of jasmine's domain and I should look for another framework for such a a task?

有没有标准的方法来做到这一点,或者是在 jasmine 的域之外进行 ui 测试,我应该为这样的任务寻找另一个框架?

采纳答案by ggozad

jasmine-jqueryis what most people use for testing UI with jasmine. It allows you to create sandbox fixtures to run your tests upon while defining most of the matchers you will need. It's pretty straight-forward and even if you do not rely on jQuery in your app, will work fine for testing.

jasmine-jquery是大多数人使用 jasmine 测试 UI 的工具。它允许您创建沙盒装置来运行您的测试,同时定义您需要的大多数匹配器。它非常简单,即使您在应用程序中不依赖 jQuery,也可以很好地进行测试。

回答by jonperl

Checkout the new kid on the block https://github.com/tigbro/jasmine-ui

结帐块上的新孩子 https://github.com/tigbro/jasmine-ui

回答by Rayjax

You should take a look at DalekJS (still in alpha) :

你应该看看 DalekJS(仍处于 alpha 阶段):

Automated Cross-browser UI testing

自动化的跨浏览器 UI 测试

回答by Jp_

I'm still looking for a perfect solution for me, but the article E2E Testing With WebDriverJS and Jasminelooks like to give a really good approach to use Jasmine with Selenium.

我仍在寻找适合我的完美解决方案,但文章E2E Testing With WebDriverJS and Jasmine似乎提供了一种将 Jasmine 与 Selenium 结合使用的非常好的方法。