How far can you go with JavaScript testing?

不打扰是莪最后的温柔 提交于 2019-12-21 20:16:13

问题


I'm somewhat informed with TDD and BDD with Ruby/Rails, but I will eventually need to use some form of testing with my JavaScript code. I use MooTools as a JS framework and I absolutely love how well I can organize and modularize my code with its codebase. But, sometimes, when I add new features to my application, I find that the functionality can easily break from how it worked before.

When it comes to testing JavaScrtpt code, does the testing itself fall short of user interaction? Is it really only to test the ins and outs of method and (emulated) classes in JavaScript? Or is there a UX testing practice where you can write unit tests to see if your application's UX behaviour is performing how it should be? I'm aware that "behaviour" is a broad term, but is there anyway that you can organize your JavaScript tests so that whenever you add something new then you can rest (somewhat) assured that your new code won't break anything from before? How is this done with any of the larger web apps out there?


回答1:


It is perfectly fine, accepted and advised to use unit testing frameworks such as JSSpec or Jasmine (there are many others).

Then, you may do UI unit, functional and sometimes even integration testing with tools such as Ghostbuster or Selenium. These allow you to fake user events and interaction.

Ghostbuster is still quite young, so we don't know so much about “actual” uses, but Selenium is an industry standard (I know it is used at IBM, source: teacher working at IBM).

However, what you can't automatically test is UX. UX stands for User eXperience, and that's not something you test on software, only with real user testing.



来源:https://stackoverflow.com/questions/8117818/how-far-can-you-go-with-javascript-testing

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