

Introducing Google JS Test - cleverjake
http://google-opensource.blogspot.com/2011/09/introducing-google-js-test.html

======
unit_testing
What's the purpose of complex testing frameworks like this? What's wrong with
using a simple framework whose tests must simply return a bool?

For example:

    
    
             var myObject = new Something("foo", "bar");	 
    	
    	 assert("simple operations", function() {
    		return myObject.doSomething() == "baz";
    	 });;
    	 
    	 assert("post-operational state", function() {
    		return myObject.state() == 123;
    	 });;
    	 
    	 assertAync("async polling", function() {
    		return myObject.poll().length > 0;
    	 });;
    

Note that those tests would be much prettier in CoffeeScript.

Is the purpose of heavy testing frameworks purely for the useful functions
like "deepEquals"? If so, why not make a library with functions like
"deepEquals" and use that library with a simple testing framework? Surely,
there must be something I'm missing.

 _Edit: I should note that the beautifully written CoffeeScript
compiler/translator doesn't use a testing framework (favoring a few simple
hand-rolled functions), and it has a massive suite of tests._

~~~
exogen
One advantage is debugging failures. If the test framework only knows that a
test passed or failed, but not why, then you don't get to know why either,
because it can't tell you.

For instance, many test runners will show you the expected and actual values
when a comparison fails. If they're large blobs of text, it can show you a
diff, etc.

------
nod
This is for unit-testing in V8 only: no DOM. I'm currently using PhantomJS,
which is V8 + Webkit and seems to be a superset of this new "JS Test". I can't
see any reason to add JS Test in addition to PhantomJS.

~~~
kodablah
Could be very helpful as a node.js addon

~~~
Volpe
Not really, node.js already has heaps of testing frameworks that work fine in
it.

------
aiurtourist
Did anyone else notice the screenshot is of a translucent terminal? I was
curious what was in the background so I played with the levels.

<http://i.imgur.com/6jifV.png> <http://i.imgur.com/cIXox.png>

~~~
Garbage
I would love to hear how did you do that.

~~~
aiurtourist
In Photoshop, I opened the image up and first chose Image -> Adjustments ->
Replace Color. I shift-clicked (sampled) each color of source code by clicking
on a few different pixel of the text. I dragged the Lightness slider to zero
to make the source code black thereby "erasing" the source from the window.

Next, I opened up Image -> Adjustments -> Levels and dragged the grey (middle)
adjustment slider toward the left to lighten the darker areas. Dragging the
white (right) slider a little left also helps to reduce the maximum blackness
of the image.

~~~
Garbage
Thank you for the explanation. :)

------
philjackson
I've been using jquery in node.js for a while now in my tests. This gives me
access to the DOM and all of the great stuff that jQuery gives us:

    
    
        @GET "/", ( err, response ) =>
          response.withJquery ( err, $ ) =>
            @equal $( "#blah" ).text(), "Something"
    

Really cool stuff.

~~~
vailripper
Have you looked into zombie.js (<http://zombie.labnotes.org/>)? It allows for
selectors as well, and is a very straight forward headless browser.

~~~
philjackson
No, I hadn't. It looks great, I'll certainly check it out properly soon!

------
rchiniquy
I've been really happy with JazzMoney:
<https://github.com/pivotalexperimental/jazz_money> I'm looking over the
limited documentation available and so far I'm not persuaded to switch. I'm
very curious about measuring code coverage - nothing seems to be mentioned
there about it, but I imagine the Goog does do that.

------
barnaby
I'm looking to branch out after having used qUnit for the last year or so.
Looks like this framework does mocking REALLY well (which I feel like I can't
do well in qUnit). But it's v8 specific, so I can't test if Internet Exploder
won't screw up my script.

Would anybody recommend any other unit-test frameworks for mocking stuff out?

~~~
lappet
You can look at jasmine + sinon

[http://tinnedfruit.com/2011/03/03/testing-backbone-apps-
with...](http://tinnedfruit.com/2011/03/03/testing-backbone-apps-with-jasmine-
sinon.html)

~~~
ch0wn
There's also a fantastic tool for running those tests headlessly with jasmine-
headless-webkit[0]. The benefit is that you can, if you so desire, test
against the DOM as there is a complete browser in the background.

[0] <http://johnbintz.github.com/jasmine-headless-webkit/>

~~~
lappet
Ah, interesting.

If headless is not what you want, js-test-driver[1] looks promising. It has
adapters for jasmine too.

1\. <http://code.google.com/p/js-test-driver/>

------
sho_hn
Anyone recognize the font in the screenshot?

~~~
exogen
Monaco 10pt.

~~~
sho_hn
Rats, somehow I dismissed Monaco as the obvious answer -- I think I'm used to
seeing it at smaller sizes. Thanks!

------
nathansobo
Jasmine.js FTW.

