JsUnit(s): The First JavaScript Unit Testing Libraries

Prologue

Edward threw the cup across the restaurant in disgust. Upon seeing the mixed reactions of the other guests, he screamed “I ordered Mr. Pibb not Dr. Pepper!” He looked at the jagged shards of what used to contain an inferior beverage and wept. He ran outside into the cold night air. What has become of me? Without a way to test JavaScript, my life holds no meaning. I should… no I must create a library that lets me…

Chalkboard with the word “test” in all caps

Intro

I have become enamored with the ways JavaScript was handled in the early 2000s. As I was ignoring calculus lectures and programming games on the TI-83 calculator, unsung heroes like Edward Hieatt were paving the way for future developers. As I was looking at a Wikipedia page to determine what testing frameworks came first and what influenced what, it was terribly unclear how things shook out. You may have come to this post already knowing this information, but I found it difficult to piece together.

The late 90s - early 2000s brought with it a movement that has helped shape modern Agile development: Extreme Programming. Extreme Programming pushed a test-first philosophy that would be further defined in Kent Beck’s Test Driven Development: By Example. Kent Beck and Erich Gamma authored JUnit, a library dedicated to unit testing in Java.

Not one, but two JavaScript versions of the unit testing library appeared as early as December 2000: one authored by Vadim Nareyko and the other by Edward Hieatt.

The one by Vadim Nareyko was fairly simple. The six-function library looked like this in 2000.

Edward Hieatt’s library, however, was a fuller solution that would not be suitable to repost here. By the way, it eventually went to GitHub. So you can go and check it out… after you fork it of course(that’s for those of us that appreciate a good git joke).

This solution initially included:

  • Test Runner HTML Page (later on they’d automate with Java)
  • Test Suites
  • Assertions

On the library’s homepage, there is a link to a Yahoo Group that contains a lot of awesome discussions.

First Topics

The group kicks off with Edward stating he’d like to provide support for browsers older than IE 5.0 and Netscape 6. This was problematic because they did not provide try..catch. Did you know that exception handling wasn’t added to the spec until ES3? And you’d have trouble living without arrow functions.

There was also discussion on how handy it would be to read and write to the local drive or server. Also, he asked if it would be useful to have scheduled testing. The project also moved on to Source Forge at this time and upgraded to support IE6.

Hello Jörg

In August of 2001, Jörg Schaible messaged the group and complained that he expected “JsUnit” to be available at Source Forge. He had started work on his port in December 1999 but was looking to publish it at that point since it was ready for production.

Jörg’s library was ran from the command line and could test environments like Rhino. There would continue to be discussion on merging the two projects and Jörg remained active in the group, but it does not appear that the merge ever happened.

Help

The group provided help to others in several cases. However, sometimes people have trouble communicating…

Hi

I have written a JS unit Test for a Java script file that talks to an
ASP page that in turn talks to a VB dll that in turn talks to
SQLdatabase.

Is this possible?

And all my functions in the JS unit test are throwing an error.

Some one if possible pls give me information on this. And my dead
line is on wednesday for the project.

Thank u.

This was sent on a Monday. This is why we have issue templates…

A couple other quotes from the group that you may find entertaining.

- Actually, IE 5.0 is very broken in comparison to IE 5.5 or IE 6.

- I’m afraid you’re confusing JavaScript with Java

The End

Based upon activity in the group, I suspect that Edward’s JsUnit was at peak usage from 2006–2007. It had a huge impact on the testing libraries that came after it as well.

As developers moved on to QUnit, YUI Test, and others, the JsUnit team packed up and moved on to Jasmine in 2012.

This post was entirely too short to capture even 1% of the effort that was put into JsUnit. You really should check out all the problems they solved with all the constraints they had. I hope you liked the post though. If you did, please share and I’ll look into doing posts on other libraries. If you didn’t… well… sorry…

Today is tomorrow’s yesterday. Make history today.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store