Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing frameworks for Javascript [closed]

We are at the beginning of a new web project that will use JavaScript and in particular angularJs. NodeJs will also be used.I am looking for the best practices in terms of automating "E2E testing" for a web project built with JavaScript.

The biggest concern is the selection of the testing framework. We are not interested in Unit tests, since this will be a task for the development organisation, however if we can merge those unit tests in the new automation testing framework, that would be a plus. So the question is "what is the optimal way to test JavaScript these days?"

The incorporation of a "reporting tool" for managerial reason would also be a plus. Are there any reporting tool for JavaScript automation tests?

A third concern is a potential need to test mixed scenarios with mobile applications. For example UserA is logged in the web browser and chats with UserB that is connected with his iPhone. How can you glue a scenario like this?

Free and open source tools are mandatory.

like image 648
cateof Avatar asked Oct 18 '13 20:10

cateof


People also ask

Can we use JavaScript for testing?

JavaScript Unit Testing is a method where JavaScript test code is written for a web page or web application module. It is then combined with HTML as an inline event handler and executed in the browser to test if all functionalities are working as desired. These unit tests are then organized in the test suite.

Is jest better than mocha?

Jest is also faster than Mocha. It has built-in support for snapshot testing, which means tests are run automatically on each change to the code. This makes it easy to keep your tests up to date as you work. Mocha has more features out of the box since it is a more mature tool with a larger community of contributors.

Can JUnit be used for JavaScript?

Because the JavaScript tests are JUnit tests they “Just work” with existing JUnit tools like Eclipse and as part of your build with ant/maven. The Eclipse UI shows every test function and a useful error trace (Line numbers only work with Nashorn).


1 Answers

To update @Vidya's answer, the Angular team is actually developing a new end-to-end testing framework called Protractor. It should be released along-side the new version of Angular 1.2. Its got some really great features and is built on WebDriver for Selenium.

It has built-in integration for running your end-to-end test suites in Sauce Labs which has some great reporting tools and will do things like record a screencast of the test running so that you can go back later and watch the test fail to see what went wrong. They also provide a bunch of different mobile device emulators that you can test your suites against so that you can test desktop and mobile browsers at the same time.

As for actual "test coverage" reporting, it can be hard to do when you're doing E2E tests because you're not truly writing tests to cover specific code statements or controllers or functions, but instead you're testing the website's functionality. So I haven't actually found any plugins/frameworks that help with doing E2E test coverage. If anyone has any ideas, I would love to hear them.

But using the combination of Protractor and Sauce Labs, we've been really happy with how our tests execute and the analytics we're able to get back with very little effort on our part. Hope that helps.

like image 97
tennisgent Avatar answered Oct 11 '22 15:10

tennisgent