Design Client-Side Code

JavaScript that runs within browsers poses some additional challenges. You’ll want to check that the code

  • Works well in all target browsers
  • Interacts properly with the server
  • Correctly acts on user commands

That’s a lot of stuff to take care of and we have the rest of the book to walk through these concerns. Right now, we’ll take the first step toward that goal—using a small example, you’ll learn how to load code into a browser and run multiple automated tests.

We’ve already implemented the isPalindrome function, with tests, to run on the server side within Node.js. We’re all set to implement the same function for the client side to run within a browser.

Open the file tdd/client/palindrome/test/palindrome-test.js ...

Get Test-Driving JavaScript Applications 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.