jQuery Conference SF 2012 Plugin Unit Testing - Get around the event loop by John K Paul

Published: 28 August 2012
on channel: Confreaks
1,023
7

For many front end developers, including me, a jQuery plugin was their first repository on GitHub. Reading that code again, I found many bugs and I am very grateful that no one ever used it in production. At the time, I was completely confident about my code working as I intended it to, but I never stopped to think twice about why I felt that way. Since then, the most significant tool that I have picked up is unit testing and the biggest hindrance in learning how to unit test has consistently been the event loop. For example, how do I ensure that particular code paths are followed when an element is clicked, double clicked, or if the window has scrolled into a particular state.

Most unit testing examples focus on very straightforward imperative tests. I have seen many explanations of JavaScript unit testing that describe how to verify the logic behind a calculator or a form validation library, but not how to test a more complex, event-triggered interaction. In this talk, I will address how to begin unit testing jQuery plugins, and how to avoid common pitfalls when dealing with asynchronous, or event handling code. Most importantly, I will explain how to deal with verifying that code is executed when native browser events fire.


Watch video jQuery Conference SF 2012 Plugin Unit Testing - Get around the event loop by John K Paul online without registration, duration hours minute second in high quality. This video was added by user Confreaks 28 August 2012, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,023 once and liked it 7 people.