BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

JavaScript Testing Approaches

| by James Chesters Follow 1 Followers on Aug 01, 2014 |

InfoQ's research widget has been deprecated. It should continue to work however, and we hope to relaunch it at some point in the future.

​​​It should not need discussing that testing, taken in the loosest sense of the word, is widely agreed to be a positive thing. While the debate over TDD continues, we can at least agree on the principles that testing bestows various benefits, including allowing us to better understand our code, and identifying bugs. 

However, what we're wondering is how you are testing JavaScript code -- if indeed you are even testing ​at all.

The options:

  • Unit Testing tools​ ​(eg. Karma)

Created by the AngularJS team and built with Node.js, Karma is designed for low level (unit) testing. Their github How It Works article says "Karma is essentially a tool which spawns a web server that executes source code against test code for each of the browsers connected. The results for each test against each browser are examined and displayed via the command line to the developer such that they can see which browsers and tests passed or failed.

Other Unit Testing tools include Testswarm, Jasmine,and many others.

  • Test ​​automation frameworks​ ​(eg. Selenium)

Originally developed by Jason Huggins and later merged with Simon Stewart's Web Driver, Selenium is an open source automation framework that provides a record/playback tool for authoring tests without learning a test scripting language. Test automation frameworks work with testing tools to automate the performing of certain types of tests effectively. Once automated tests have been developed, they can be run quickly and repeatedly. 

Other Test Automation Frameworks include QUnit, Sahi and many more.

  • Functional testing​ ​(eg. Cucumber)

Functional testing is a type of black box testing that bases its test cases on the specifications of the software component under test.  Functional testing is based on testing the functional requirements of software, and ensuring that the program physically works the way it was intended.

Specifically, Cucumber lets software development teams describe how software should behave in plain text. The text is written in a business-readable domain-specific language and serves as documentation, automated tests and development-aid. Other Functional Testing tools include Capybara, among others.

  • I don't test

In the comments, please add a bit more information about ​how you are testing, and if you are testing​. 

Does the size or nature of the company you work for have​ any impact on​ how you test? Perhaps you have found very different attitudes and approaches towards testing depending on the project or company. 

If you aren't testing, again let us know your experiences in the comments.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

And TDD ? by Ivan Pierre

Is there a necessity to add a lot of code to make tests ?

Re: And TDD ? by Charles Humble

There's an interesting presentation on TDD and productivity here -
www.infoq.com/presentations/tdd-original
Well worth watching

Human review of javascript/ui behaviour by Juan Pablo Araya

We have a mix of of javascript inside asp files and .js files; most of them points to specific html tag elements so it's impossible for us right now to automate tests for javascript.

It's a legacy code with more than 15 years old. Is there any possibility to test this kind of code without human intervention/with automated tests?

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

3 Discuss

Sponsored Content

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT