Live data from Hacker News

Ask HN: What do you use to test Frontend code?

news.ycombinator.com

11–20 of 47 posts

Re: Ask HN: What do you use to test Frontend code?

#11
Having dealt with the Selenium and its frustrations in the past, I tend to outsource this sort of testing if at all possible. Some things can only be truly tested with eyeballs.

One tip I do have is to disable jQ animations during your test runs so you aren't having to jump through hoops in your test suite just to wait through animations -

jQuery.fx.off = true will do that.

Re: Ask HN: What do you use to test Frontend code?

#12
on a side note, do you people test graphics? I mean, it's kind of easy to say "I get a div #foo". But how do you check if it has the right shade of $color and a rounded corner and the text content is not overflowing the containing box?

I live in constant worry of changing css and totally screwing up a completely unrelated bit of the web app, and the usual thing I get told is "well, it's very fast to check if it still works", which reminds me of me not understanding why unit testing is useful.

Re: Ask HN: What do you use to test Frontend code?

#15
I use a custom selenium test runner that runs them in parallel (php). I plan on neatening it up and releasing it at some point if theres interest.

It also has a 'live mode' which is useful for writing up new tests. It basically follows a file and whenever there is a change it begins running the commands from that line onwards again. If it hits an exception it'll pause there and wait for you to fix the broken test/site before resuming.

Re: Ask HN: What do you use to test Frontend code?

#16
Some things require manual testing. Animations and a lot of visual stuff needs to be analyzed holistically; there are sometimes visual quirks that are near impossible to write tests for but can easily be detected from someone quickly viewing the site.

Have different environments set up. After every big push, run through a simple user flow to make sure what the user will actually see is what you intended.

Re: Ask HN: What do you use to test Frontend code?

#17

I guess Selenium is fine, out of curiosity, why do you think using Selenium isn't the right choice for you?

I'm not sure that it isn't. I'm worried about the maintenance costs of keeping it up to date - but maybe that is the price you pay.

Re: Ask HN: What do you use to test Frontend code?

#18
I use qUnit all the time because I wrote lots of jQuery plugins for everything that we do at my small startup. Then we have a QA team in India that are always clicking through the site and finding new bugs (they also have extensive selenium scripts that go through the whole site every night, but oddly enough none that run the unit tests... grr).

Re: Ask HN: What do you use to test Frontend code?

#19

on a side note, do you people test graphics? I mean, it's kind of easy to say "I get a div #foo". But how do you check if it has the right shade of $color and a rounded corner and the text content is not overflowing the containing box? I live in constant worry of changing css and totally screwing up a completely unrelated bit of the web app, and the usual thing I get told is "well, it's very fast to check if it still…

Why is unit testing useful, to you?

I have often heard two justifications for testing: (a) correctness and (b) developer speed.

Phrasing (a) differently, is X functioning as intended? Phrasing (b) differently, how quickly can I make a change to Y, and if I change Y, how long will it take to manually check Y (with a browser, etc.), how likely am I to introduce a bug (leading to extra development time) and/or will I have to rewrite a test?

If your primary justification for testing is developer speed rather than correctness, does that impact which features (models, controllers, views with div ids, actual view graphics) you should write tests for?

Re: Ask HN: What do you use to test Frontend code?

#20

I guess Selenium is fine, out of curiosity, why do you think using Selenium isn't the right choice for you?

I'm not sure that it isn't. I'm worried about the maintenance costs of keeping it up to date - but maybe that is the price you pay.

If you're worried about keeping it up to date, why not outsource the test runner to something like saucelabs?
Post reply on HN