WORKING WITH JAVASCRIPT
Many web developers have a love-hate relationship with JavaScript. In most situations, web developers don't hate JavaScript per se; they hate the Document Object Model (DOM) in most web browsers. In recent years JavaScript frameworks such as jQuery and Prototype have relieved the pain that the DOM has caused web developers. These frameworks make it easier for you to work with the DOM and reduce the number of tests you need to create to test your JavaScript. Remember, you don't need to test the framework.
One of the most common mistakes web developers make when it comes to JavaScript is not abstracting their logic into different files. Many developers chuck everything into one script file or duplicate functionality over many different web pages. They don't realize that testing frameworks exist for JavaScript, or that you can create JavaScript using TDD methods.
JavaScript is a real language, and code should be treated as such. Rules that you have learned about SOLID apply to JavaScript. When JavaScript code is created in this manner, it is easy to test and maintain. Some web developers complain that an HTML page that is required to download multiple JavaScript files loads slowly, and they are correct. Using techniques such as combining and minifying during the build process resolves these slow page load issues. Testing performance is a different topic; for now I will focus on creating testable code.
JavaScript Testing Frameworks
As with most languages, multiple ...
Get Professional Test-Driven Development with C#: Developing Real World Applications with TDD now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.