javascript tutorial - [Solved-5 Solutions] Javascript unit test tools for TDD - javascript - java script - javascript array
Problem:
I've looked into and considered many JavaScript unit tests and testing tools, but have been unable to find a suitable option to remain fully TDD compliant. So, is there a JavaScript unit test tool that is fully TDD compliant?
Solution 1:
Take a look at the Dojo Object Harness (DOH) unit test framework which is pretty much framework independent harness for JavaScript unit testing and doesn't have any Dojo dependencies. There is a very good description of it at Unit testing Web 2.0 applications using the Dojo Objective Harness. If we want to automate the UWE testing (a sore point of many developers) - check out doh.robot. The latter is designed for an acceptance testing. Update: Referenced articles explain how to use them, how to emulate a user interacting with our UWE using mouse and/or keyboard, and how to record a testing session, so we can "play" it later automatically.
Solution 2:
WE created an open source project called Chutzpah which is a test runner for JavaScript unit tests. Chutzpah enables we to run JavaScript unit tests from the command line and from inside of Visual Studio. It also supports running in the TeamCity continuous integration server.
Solution 3:
The JavaScript section of the Wikipedia entry, List of Unit Testing Frameworks, provides a list of available choices. It indicates whether they work client-side, server-side, or both.
Solution 4:
There is also BusterJS from Christian Johansen, the author of Test Driven Javascript Development and the Sinon framework. From the site: Buster.JS is a new JavaScript testing framework. It does browser testing by automating test runs in actual browsers (think JsTestDriver), as well as Node.js testing.
Solution 5:
We are now using Qunit with Pavlov and JSTestDriver all together. This approach works well for us.
- QUnit
- Pavlov source
- jsTestDriver, source