O'Reilly logo

Enterprise Web Development by Victor Rasputnis, Viktor Gamov, Anatole Tartakovsky, Yakov Fain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Test-Driven Development with JavaScript

To shorten the development cycle of your web application, you need to start testing it in the early stages of the project. It seems obvious, but many enterprise IT organizations haven’t adopted agile testing methodologies, which costs them dearly. JavaScript is a dynamically typed interpreted language—there is no compiler to help identify errors as is done in compiled languages such as Java. This means that a lot more time should be allocated for testing JavaScript web applications. Moreover, a programmer who doesn’t introduce testing techniques into his daily routine can’t be 100 percent sure that his code works properly.

The static code analysis and code quality tools such as Esprima and JSHint will help reduce the number of syntax errors and improve the quality of your code.

Tip

We demonstrate how to set up JSHint for your JavaScript project and automate the process of checking your code for syntax errors in Chapter 5.

To switch to a test-driven development mode, make testing part of your development process in its early stages rather than scheduling testing after the development cycle is complete. Introducing test-driven development can substantially improve your code quality. It is important to receive feedback about your code on a regular basis. That’s why tests must be automated and should run as soon as you’ve changed the code.

There are many testing frameworks in the JavaScript world, but we’ll give you a brief overview of two ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required