Re: Testing Javascript

"Jonathan Lange" <[email protected]> Thu, 26 Jun 2008 17:34:19 +1000
Newsgroups gmane.comp.python.quotient.dev
Message-ID <[email protected]>
On Thu, Jun 26, 2008 at 5:13 PM,  <[email protected]> wrote:
> On 12:28 am, [email protected] wrote:
>>
>> Sometime back in 2006 I worked on some Javascript testing stuff with
>> Divmod. I'm vaguely interested in what's happened with it, but that's
>> not the main point of this email.
>>
>> What I'd really like to know is what's your overall strategy to
>> testing Javascript on your websites. What tools do you use? Do you
>> have it integrated into your main buildbot runs? Is it fast? What are
>> your main gripes with what you've got?
>
> As far as I know, not much has changed in the test support code that you
> wrote.  We're still using it.  It's integrated into our buildbot runs
> (although our buildbot is a complete mess at the moment, a disaster area
> that I hope Allen will get to fixing soon).
>
> It's perfectly fast; we've never had a problem with speed, AFAIK.
>

I seem to remember loading testing pages in my browser that took ages to run.

> My main gripe with it is that it's a poor integration environment.  The
> JavaScript test environment is radically different from a browser, and we
> don't have enough test support code that emulates different browser
> behaviors.  Ideally, any test that touched the "document" or "window" object
> would be run multiple times, with behaviors for each browser.
>
> There's also the fact that it's unreasonably difficult to get something
> approximating the actual DOM structures that the code will be operating on
> into the test environment.  For the cleanliness of the tests this is
> actually a good thing; it forces the code to be more independent of the
> resources it's operating on.  However, it also makes the tests less
> realistic, because it forces you to replicate a minimal representation of
> the data dependencies and there's no way to make sure that it's an accurate
> minimal representation.
>

Right. Any fake DOM would have to be tested itself with interface
compliance tests that run it and the DOMs of your supported browsers.
Any environment that let you do that easily would also let you just
write the tests without needing a fake DOM :)


> Is that what you're looking for?
>

I think you've focused mostly on the unit testing stuff I worked on
ages back. ISTR you have any integration tests for JS stuff that talk
to the server? (I definitely recall big testing pages that took ages
to load). Do you still do that? How does it work?

It may be that I'll just have to update my Divmod trees and figure it
out myself, but I'd rather go the easy route and ask first.

jml