5 Free Copies of Test-Driven JavaScript Development

5 Free Copies of Test-Driven JavaScript Development

In addition to donating an excerpt of his excellent new book to Nettuts+, Christian and Pearson books have also been generous enough to provide us with five digital copies of the book to give away.


How to Win a Copy

Despite the fact that the JavaScript language has grown in leaps and bounds over the last few years — in both features and popularity — it’s still one of the most least tested languages. Why do you think that is? Leave a comment and let us know your honest opinion. On November 22nd (EST), we’ll choose five winners, and send them a free copy of the book! That’s all there is to it.

5 Free Copies of Test-Driven JavaScript Development

Tired of console.log-ing your way out of trouble? Weary from constant fear of cross-browser issues? Scared of making even the slightest change to production code? Test-Driven JavaScript Development teaches you how to solve those issues and more using unit tests and TDD. Rich with examples, the book provides a solid foundation on automated testing, a test-driven walk-through of JavaScript’s unique qualities, and five practical examples of building solid, reusable, cross-browser JavaScript using TDD.

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Scott Allen

    Testing JavaScript is super important. When building sites I have to beware of all the IEs, Chrome, FF, etc, and there are random times with IE works, but Chrome throws errors on me. FF is the most lenient of the browsers I think, but Firebug is the most powerful tool out there for debugging any JS issues – Chrome and IE developer tools help, but aren’t great. Being able to know how to test cross browser would be great for me, because a lot of our clients still primarily use IE7 and IE8 (and one still uses IE6 – ugh).

  • http://lesslines.com Ivan Malijkh

    There is so little attention to test driven development when learning Software Engineering at school.

  • http://www.anglesharp.com Matt L.

    In its early stages, javascript was used primarily for minor tweaks and features like image rollovers (blah!). Only since the (relatively recent) shift towards object oriented development in javascript has any testing framework been necessary. Hence the rise in popularity.

    Would love a book on the subject! Thanks!

  • http://bdewong.blogspot.com Brent

    I believe that JS is one of the least tested languages because it is a client side language and many experienced people are using it. Not only that, but there aren’t many resources outlining testing procedures and most of the tutorials don’t include testing. People end up just copying some bit of code and using that.

  • http://jaaulde.com/ Jim

    JavaScript is an easy entry point for anyone who wishes to try programming, is used primarily to build the unstructured web, and its primary platform is the browser which for so long (and in many cases still doesn’t) didn’t have any real hooks into the JS being executed. This all adds up to a widely untested language.

  • http://www.sweetwater.no Kris Selbekk

    I think the reason it is not tested as much as other languages, is that it “kind of works” even when it shouldn’t. Thus, people are satisfied with shifty solutions that produce errors, yet still work in the way they were designed. Also, there is no popular standard (like the W3C one for HTML and CSS) as to how code should be structured.

  • Ray

    Javascript being least tested language because usually web application is less complicate then traditional desktop application?

  • Bill

    It’s tested so little because so many of us “grew up” winging it before we understood the benefit of test-driven dev. Now get off my lawn, you whippersnappers!

  • Amayreh

    - Considering JavaScript as a utility language makes it less important to be unit tested
    - The lack of Unit test tool that can be integrated into popular IDEs

  • Habib Rosyad

    It’s because JS is a client side language, therefore the test must be take on client side or at least an environment which simulate these. As we know there are a lot of type of client side environment/platform, be it like the OS or browsers, we must take it as consideration when doing the test. For instance, the correctness of implementation depends on whether you run it in Firefox, Opera, Safari, Chrome or IE. It is also difficult to pretend which version of above browsers will be used. That really make a hard time for developers to think about a lot of possibilities while building all cases, and how the test will be done.

    Above all maybe we want to do the test automatically, as we modified the code. The biggest problem may be how the hell it can be automatic, as we know there are a lot of browsers out there to do the test, and the results maybe different for each, and the only solution that cross our mind maybe just press F5 again and again to get the exact results.

    In the end for some of us maybe it just a pain in the butt to do all of this testing thing, except some JS ninjas willing to teach and convince us how easy it will be done (THERE FOR, GIVE ME THE BOOK PLEASE… hehe).

  • http://www.shekhardesigner.com $hekh@r d-Ziner

    b’coz its toooo easy.

  • vaff

    My two cents on TDD or JavaScript testing is that JS has become so “easy” that most people never get their hands dirty with actually JS, it’s all just a new pseudo language with all the intelligent frameworks that exist now. Its not uncommon to see code like this:

    var value $(this).val();

    when

    var this.value;

    would do exactly the same… In my opinion that is one of the main reasons people never really test their JS, they just know to little about the language. They expect it to be a quick and dirty language for effects and fun with zero to no maintenance.

  • David

    sounds like a great book to bringing your JS skills to the professional developer level

  • http://blog.arieh.co.il Arieh

    I think that much like other interpreted languages, javascript prompts learning by tria and error, rather than planning. There are very few good guides on how to use it, and even less on JS as a language by its own rights, rather than a means to manipulate the DOM.
    It’s not just about TDD. Many of the common JS programmers today don’t know the DOM by itself, don’t understand how closures truly work, not mentioning prototype-hierarchy. Many today don’t even know that JQ is not a language by itself.
    The last reason, as I see it, is that for many people, JS is a functional language. That is obviously ironic, since JS functions ARE objects, but traditionally, TDD find it’s home with OO programmers.
    The truth is, I think that the only case where JS programmers use TDD is that they already know it by heart from another language.

  • http://rutwickgangurde.wordpress.com Rutwick

    Cause everyone wants to be on the server side!

  • http://www.dewebmakers.nl/ Webdesign Bureau De Webmakers

    Sadly i’m not that good in test driven javascript developement. Maybe this book will shine a light..

  • http://www.seo-geek.de Daniel

    I think because libraries like jquery and mootools makes it as easy at is can be.
    For most of the “small” developers out there, there is no need for testdriven developement.
    I recently begin in php with test driven developement. it’s hard at first, but way cooler at the end.

  • przemeko

    Becouse js have very short learning curve. It’s very simple to develop working app in very short time (without deep understand how js really works) – so developers don’t worry about testing.

  • Raph

    I think it’s not really intuitive to make tests before in javascript, because there are too many differents factors which will change “the reaction” of the code on different browsers/javascript engines. Is there a way to write a test which will work well at the first time on differents browsers ? I don’t know…

    @Rutwick: Not everyone wants to be only on the server side, if it was the case there would’nt any site/ihm…and the server side won’t be usefull :D

  • http://www.deafness-and-hearingaids.net Steve

    Possibly because the large majority of Javascript that is written is small snippets of code that people don’t think are large or complicated enough to warrant a test

  • http://amrelgarhy.com Amr Elgarhy

    I think it is hard for javascript to be tested because it is very coupled with some other UI technologies, such as html and css.

  • Sam

    Web development (including javascript programming) is often done by those with little or no computer science/programing training. Untrained programmers tend to macgyver together bits and pieces of things they find online and test it until it works. This tends to be “good enough” because interesting things can be done with very little javascript code especially if libraries like jquery are used. I believe this is trend caused by so many organizations wanting a web presence while too few knowledgable, inexpensive, and accessible programmers are available.

  • http://alternates.org Ege Özcan

    JavaScript has been a language that tried to survive on top of the DOM for years and before the libraries like jQuery neutralized the differences between browser implementations, you had to write the same functionality for different environments, nearly from scratch. That made the developers lose too much time on “just making it work”, so very few could go further and test or re-factor their code. Most people learned JavaScript just for web page enhancements. Now that we have these awesome frameworks and additional -popular- usages of JavaScript (like Node.js), it is becoming more and more important to write tests and output a clean code. If you separate your logic and have a platform-independent code-base, you can move your application back to the server side, push it to the browser or just make an AIR app with it. Decision is yours.

  • http://www.impressivewebs.com Louis

    In a video presentation for his book JavaScript: The Good Parts Douglas Crockford summed it up well:

    JavaScript is the only language that I’m aware of that people feel they don’t need to learn before they start using it.

  • Absalan

    Also there are many comments here. But since I’m interested in having the book just am hopeful to be a winner.
    :)

  • http://www.w0rldart.com w0rldart

    Javascript is least tested because people (me) got to comfortably using frameworks but now it has to change.

  • http://www.miceover.com Marco Segreto

    People often don’t test in Javascript because many of the people that write JavaScript don’t come from a computer science background. Also, many of the editors that are used for JavaScript don’t feature testing tools.

  • Marcin

    It’s probably because it’s a complimentary language. You build pages in ie. in PHP and you need to test it, but since js is only a small part, not many people goes through hassle of testing it thoroughly.

  • http://hector-lee.com Hector Lee

    Since javascript is actually the most cross-platform capable code, it is actually still very useful for development. Especially with the current surge of web apps. It can also be used for developing mobile app as they can be compiled into native apps.

  • Igor

    Javascript is the least tested language because most programmers only see it as a simple scripting language that is used to pop alert boxes and to do simple image galleries. What they don’t realize is that it is a very powerfull language, so powerfull that it changed the way we interact with the web. But without proper testing, one cannot unleash its full power.

  • http://mrdustpan.blogspot.com Dustin Brown

    For me it’s all about tooling. As a .NET developer it’s easy to do TDD because you have many testing frameworks (such as NUnit) as well as mocking frameworks (like Moq). If there were tools like this for javascript testing (and there probably are, I just don’t know of them) I would do a lot more javascript TDD.

    Also, an important part of unit testing in general is the ability to easily run all of the tests on a regular basis, such as part of a build or continuous integration process. Whatever testing frameworks are that out there would need the ability to integrate with a CI server such as CruiseControl.

  • http://thomasjbradley.ca Thomas J Bradley

    I agree with what many people are saying: it’s just starting to be considered a ‘real’ programming language (though it already was) and TDD isn’t a topic that really comes up often when taught Javascript.

  • Jryanj83

    I believe this lack of thorough testing comes simply from the enormous breadth of the javascript language. It is so vastly deep that every browser has it’s own set of idiosyncrasies to deal with javascript in it’s own special way. Lets we forget the multitude of approaches there are to the many problems javascript solves. I see these as the main contributors to the reasoning some use to ignore testing their code… Please, please (if you don’t already) start testing your code fully and go back over it time and time to get as lean as possible. You won’t just be helping yourself!

  • Matt

    I suspect that the reason javascript so rarely undergoes formal testing during the development process is simply because people are used to writing small things with it. It has historically been used for small enhancements to a site, and testing was seen as a waste of time for something no more than a couple of hundred lines. Once this habit has been established, it becomes difficult to break as javascript applications become increasingly-large projects that move from small enhancement to the forefront of development.

  • http://www.littlefyr.com Adam van den Hoven

    I once wrote a JS library (which is now lost forever in the bowels of a closed corporate SVN repo somewhere) that would parse prose into date. Like “tomorrow” but also “next month” and “23 weeks from now or even “32 days from last monday”.

    Pretty neat stuff but the regular expressions I had to write were very unusual. The only reason I could have gotten it to work at all is I had decided to try out one of the JS unit testing frameworks. It saved my life but I would really like to start doing more TDD with my JS. This will make my life a LOT easier.

  • http://poetro.hu/ Peter Galiba

    A lot of developers use JavaScript in their every day development, as the entry level is one of the lowest. And also JavaScript is the most widely used programming language ATM. This leads to the fact that most of the code is not tested, as there are a lot of developers that do not care, and also it is not that trivial to test JavaScript code, than any other language, as JavaScript is more event driven then anything else.

  • http://paulgladstone.net PG

    Quest Driven Development

  • .ph

    i like client side programming, Maybe i get this book,

  • http://jammyspeaks.com Saurabh

    JS could be said least tested as -

    1. It is a client side language. And client includes both newbies and experts. We can say about experts testing it (am not sure, as most of them are out sourcing their work to freelancers!), but newbies are just using it without running any tests.

    2. JS is one of those languages whose plugins are easily and freely available over the web. So its a general habit of many to just use it without checking the compatiblity.

  • Vernie Lariosa

    It is because.. it interacts with the users…. more interactive..than any other languages that exist.easy to understand

  • adamcodes

    The reason there isn’t a lot of investment in JavaScript testing is it can be turned off, with a few clicks in the browser. There’s a leap of faith for all levels of JavaScript.

  • http://twitter.com/logandonley Logan

    I think that javascript isn’t as widely tested because it isn’t a major language that is used for massive corporate projects. I think that programs like php, java, asp, C, C++, etc. are all very well developed and tested because they are capable of coding big systems. This being said programmers are more interested in these other languages because they know that there are always job opportunities and it is in the interest of powerful companies. This is just my opinion. Javascript isn’t a language which is used in the corporate world as much because while adding a few interesting portions of the front page of a site, it really isn’t on top of the priority list of larger technology firms.

  • http://twitter.com/ooredroxoo Rafael Nascimento Sampaio

    The very reasons may be
    1) Browsers have different DOM engines that mess with code what for some developers can be painful make a crossbrowser script, so they may think that test is more painful yet(write the test).
    2) For be a client side script mostly used on commom web pages with simple interface for simple purposes some may not even consider make a test to such a easy thing.
    3) Some people just like trial and error, so they don’t test, other may don’t even know that javascript can be tested.

    Probably the most significant reason or fact is that the people that do more test are the people that develop web apps, becuse they must be expansive, reusable and the development process can’t be stuck for someone that don’t test to know performance and memory leaks stuff.

    Javascript has a lot of good parts, has been penalized with the web standards trend of provide support for people without javascript and don’t use javascript without purpose(not that as wrong, just some people start to hate javascript for misunderstanding).

  • Steve Robillard

    I think it is related to a comment I saw earlier this week. The author conditioned his question by claiming JavaScript wasn’t a real programming language. This perception I think drives it. Second I don’t think there is a culture/infrastructure built around JS – rather it is seen as something you add as window dressing at the end. This is slowly changing as JS becomes more important to web development.

  • Jayar

    I think that people don’t test Javascript because it’s really not a large component of the overall development. There may be only a handful of lines of JS vs. hundreds of lines of PHP, CSS, or HTML.

  • K Arun Mariappan

    I always like the TDD in the Software Development. I like to have the same for the JavaScript.

  • http://www.connect-green.com NetChaos

    Have no valid reason to comment, just trying my luck to get an useful book.

  • Fabian

    I think JavaScript is the least tested language, because not long ago everyone was just happy to get JS working across different browsers. Nowadays where JS evolves from a little helping language to a prime player of programming languages it’s time to treat it as one and test it really well.

  • Amit

    I’ve learnt most of the JS through net.tutsplus.com (I had never used it before, because it looking complicated, but then I found this site and I Love It!!!). I’m really looking forward to learning lots of other things here!

    Great job!

  • nico_nico

    One reason
    Javascript, just as HTML and PHP, was often self-learned by people who want instant results for personnal projects. I don’t mean to be haughty, I’m one of those, but I have to say that I was introduced to TDD only very recently.
    Javascript has also been rejected for years by some developpers who didn’t think this is a pro language (loose typing, interpreted code, not a true OO language…).
    With amateur developers not knowing TDD and pro dev underestimating and rejecting it, Javascript was not given a chance to access testing tools.
    Now, this is only changing because Javascript is considered among respected technologies thanks to great devs and companies that showed everyone it was worth using.