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
  • Spencer Westwood

    I think the main reasons for Javascript not being written using TDD before (and testing in general) is lack of direct tools integration for testing. Sure you can cobble stuff together to output to firebug, but it needs to feed into a testing system for continuous integration testing.

    The smattering of JS testing libraries that do exist such as qunit don’t really play nicely with other integration tools and I know I’ve tried using a combination of selenium server, hudson and few other tools and its very difficult to get things integrated right. This also blurs the testing between unit test and functional testing somewhat.

    Then on top of that if you’re using a javascript library such as jquery (yum!) I’ve yet to work out just how to unit test certain functions that are entwined. Often its easier just to check the functional testing works instead and then dig deeper if it fails – especially with Ajax calls.

  • http://www.stephenburgin.me ThaBurg

    Time, I think it all boils down to time. Or I guess it’s the illusion that we don’t have time and that it will be quicker if we wait till later to do some good rounds of testing. It takes time to test your applications and we’re lazy so we put major testing off until the end… because, well you wrote the code so it should be perfect right? This is also the reason we avoid or put off many things that are “best practices”, OOP, UML, Use Case Testing, User Group Testing, Cost Analysis, etc. Most developers love to code and that’s what they want to do, just write something.

  • http://maydey.com Jordan S

    I think Javascript is the least tested because it is easier to get it to ‘function’ in the practical sense off the bat or with little knowledge. When I first started using JS, it’s ease allowed me to plow through several thing I wanted to do, yet there was little testing because I was flying through it so fast.

  • http://www.mattchu.com Matt – Microbrew Media

    Looks like a great book. Have PHP & MySQL by the same publisher. Haven’t learned too much on JS yet, but look forward to in the coming months. This would help too!

    Cheers

  • http://christophgockel.de Christoph

    Being a test addicted software developer myself, I think the main reason test-driven (or at least test-followed) JavaScript is not very widespread is, that many of todays JS “developers” have no clue that something like an automated testing-framework does exist. And even don’t know what it buys them – and more important: how it could help them make their life _so much_ easier.

    I’m not insulting here, but in my experience, most of JS developers I met, learned programming many years ago. The things they learned back then, they use today. And nothing more. But for me, there is a difference between being a programmer and being a developer.

    I mean come on. It’s not that unit-testing or TDD is something esoteric or that hard, that you couldn’t learn how to do it. And therefore learn how to being a better developer. Since a testable software will be most of the time a software way better designed. Not even to mention how it directly affects maintanability and sustainability…

    And yes, all those parts are getting more and more important for JavaScript-Applications. Since the current JavaScript uses are not just “web-apps” or some little scripts used on personal websites. Professional JavaScript is getting more and more important.

    And being a professional developer means you know how to develop “good” software – and not just how to program a function “which can do …”.

  • Antonio Stoilkov

    I think the reason is people underestimate the importance in JavaScript optimization and performance and really don’t understand actually how fast JavaScript is.

  • http://scottpovlot.com Scott Povlot

    JavaScript is now being taken seriously as a real application programming language. So, developers now need to invest time for quality. Unit testing and functional testing are the keys to quality. Test Driven Development requires good unit testing. Up til now JavaScript has been seen as a simple effect tool so testing hasn’t been a priority. Testing is now key to good quality development.

  • Yader Hernandez

    Not too long ago…

    No one saw javascript as a real language. It’s simplicity has caused many developers to think that because it’s so simple that the need for tests were not necessary. That may be true for small applications but once you step into the ring with enterprise applications, its a whole new ball game.

  • m

    First (obvious) – javascript works differently under different browsers (yes! im pointing at IE mostly). It’s harder to test under many browsers.
    Two – Hard to test interaction, users behaviours (its not only js but also usability problem)
    Three – no proper tutorial/book about unit testing for js
    Four – laaaaaaaaazyneesssssss ;)
    Five – not many people has this book yet.

  • phon xay

    I think Javascript has been known earlier as a script junky language and people notion of its significant was not noticed until the arrival of Ajax. Earlier practice of using Javascript was just adding features to make the webpages semi-interactive and it all about cut and paste script from each others without much thought of testing the code for venerability but instead concentrated on solving a problem with a quick solution.

  • http://www.mariusstuparu.com Marius Stuparu

    Maybe there are too many frameworks, and the users are not very connected to the other frameworks. Also, I think it’s not perceived as a complete development language, and so nobody bothers to develop testing environments.

  • http://campino2k.de Chris

    I think, the reason is that most developers associate JS with the sick browser implementations.

  • http://aeweb.ca Rodrigo Flores

    Because Javascript did not have as much popularity before the phenomenal libraries that came out over the past few years. Most people’s projects were browser specific. Moreover, testing requires some extra coding most people don’t understand.

  • http://tookooldoggies.blogspot.com Elena

    I think that the simplicity of frameworks like Jquery have made developers realize that coding pure Javascript isn’t as important as it used to be. As a result, it’s not tested as much unless you love Javascript and are trying to innovate the language.

  • Jordon Allen

    I think the reasons behind why JavaScript is not tested that much is because JavaScript can vary so much and be personalized. As well as there are a lot of web developers just using snippets and putting the code together, as far as testing the code themselves.

  • http://chang2034.wordpress.com javier

    I think it is because it is a complicated language with the naked eye, although the new libraries like jquery or mootools make it easier to integrate, and especially the number of tuts. and contributions from anonymous users.

  • http://www.he8us.be Cedric

    I see four main reasons about the fact that JavaScript is under tested, but first I will explain what I do with JavaScript.
    I’m some kind of Front-End Developer but in my country we are called Web Integrators: we do html slicing, image optimisation & JavaScript development client side. I do a lot of JavaScript (80% of my work time is spent playing with JavaScript) but all of these scripts are animations: sliders, carousels, lightboxes, … Now, let’s begin the reasons I see why JavaScript is not really efficiently tested.
    First one, lot of “JavaScript developers” doesn’t have a classic scholar background as developers (maybe just in my country, but I guess it’s the same outside), I work every day with people that copy-paste the scripts from the web just because they don’t take the time to learn how the language works. I know, I hate to give them the label “JavaScript Developers” because they are not; but what is the percentage of JavaScript users that really know JavaScript? I’m kind of sure that people who knows JavaScript knows how to test it.
    Second, I don’t think JavaScript is so much under tested; he’s manually tested not automatically like with Unit Testing. The main part of my work is creating animations, I test them but manually, how can you automatically test that your box is slightly fading out instead of just disappearing?
    Third, teachers. Teachers! I don’t know you but when I was at school I learned COBOL, Pascal & Assembler. Oh yeah! In Belgium when you work for the public administration you can work there all your life, even if you’re dumb, slow and an asshole combined. Same for teachers. I gave a JavaScript lesson to a friend, after two hours at school he was totally lost. The course was named “Introduction to Java-script” (spelling is important) and the first chapter was “Creating classes”. Wtf? Prototypes at first sight? He didn’t even know that there is no foreach in JavaScript nor the existence of the global object ^^ But he knows how to create classes. How do you want a teacher that is discovering JavaScript with his students be able to test it in an other way than manually.
    And last but not least, JavaScript was considered only able to check value from a form or just able to simulate snow on screen. And that for ages. Who really wants to invest in that language? Just some Geeks with great minds but no money so there’s no real formation available (I mean, everything from A to Z at the same place) and able to give you the key to really understand what is JavaScript and how to develop and test efficiently.
    But all of that is just a blast from the past, with the language popularisation more and more tools are created to help us develop (jQuery, Dojo) and test (QUnit, js-test-driver). Better JavaScript testing is just a matter of time…
    So voilà, there’s my thoughts about JavaScript testing…

  • http://www.floatingpoint.ca Aishwar

    The most annoying thing is the extremely tight view integration. A lot of the javascript we write, at the end of the day has to manipulate the DOM. How do you test this (yes, it is possible, but…read on)? And to test it you need a browser, launching, closing, relaunching browser sessions for each set of tests is plain painful and extremely slow. And in reality you do not even care, how the DOM looks, you just care about the visual output (testing this browser to browser is a whole new ball game).

    I’ll stop the rant, more objectively:
    – It is slow to develop, slow to execute and kills your productivity (launching, closing, relaunching browser test after tests – as in jsUnit – takes painfully long and freezes you from using your computer do do any other work).
    – Developing tests is a long painful process (write an HTML page, set up everything – the tight view integration causes you to do a lot of setup)
    – When you use timeouts etc. Javascript tests can be surprisingly brittle
    – You do not have strong controls to check for DOM readiness, event (in timeout) execution completion etc.

    Though, the js-test-driver seems like a breadth of fresh air. I love the fact that the browser can stay open and your tests just use it, they can execute in an automated fashion etc. Now I just need to figure out how to decouple the view from the model and controller in our web app to enable better testing using this cool piece of technology.

  • http://interactivearmy.com Mike Sheridan

    My opinion is that is can be a troublesome painstaking task in debugging javascript across all browsers. The fact that it has jumped in popularity over the last few years, however beings it is hard to anticipate every problem that may arise across all browsers and os’s is extremely time consuming. We as developers try to assume as much as possible but testing everything is almost impossible when working within a budget especially when working freelance.

  • Roman

    Same reason why PHP is not tested well. It’s a popular language and even amateurs use it a lot. People get to learn it in schools but mostly nobody teaches tdd or even a testing! Very unfortunate but reality.