BT

InfoQ Homepage Research JavaScript Testing Approaches

JavaScript Testing Approaches

Bookmarks

InfoQ's research widget has been deprecated and is no longer available.

​​​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.

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

Community comments

  • And TDD ?

    by Ivan Pierre /

    Your message is awaiting moderation. Thank you for participating in the discussion.

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

  • Re: And TDD ?

    by Charles Humble /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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 /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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

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

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.