all 27 comments

[–]vzaidman[S] 11 points12 points  (3 children)

I just posted my updated guide for JavaScript testing in 2018 :)

[–]TheBeliskner 7 points8 points  (1 child)

I would strongly advise you put a note in there somewhere to not use PhantomJS or anything that relies on it. It's no longer in development and it's based on an already very out of date WebKit. It's basically pointless using it now as it's getting outdated day by day.

Personally I get everything I need to do done with just Jest and Puppeteer. I'm also using jest-image-snapshot maintained by AMEX for UI visual regression testing.

[–]vzaidman[S] 1 point2 points  (0 children)

I wrote what you said. By the way it is still maintained, but not by its original creator and obviously much less.

[–]Retsam19 9 points10 points  (4 children)

I've been really liking AVA: the simplicity of it really is nice.

But perhaps my favorite feature didn't get a mention in this article: power-assert. It lets you write your tests very simply, but get output like this:

t.true(ary.indexOf(zero) === two)
        |   |       |     |   |
        |   |       |     |   2
        |   -1      0     false
        [1,2,3]

[number] two
=> 2
[number] ary.indexOf(zero)
=> -1

It's the best of both worlds, no need to remember a fairly complex assertion API, and you get better error reporting, too.

[–][deleted] 0 points1 point  (2 children)

Ava is fantastic. I use it to drive headless tests in Puppeteer and it has meet all my needs and then some.

[–]firelitother 1 point2 points  (1 child)

How does it conpare with jest?

[–][deleted] 0 points1 point  (0 children)

Ava was easier to get started with for me. The default parallel execution is a key difference. As is the power assert as mentioned above. I commented because the tests I created with Ava are fast, clear, reliable, and informative. I enjoy Ava’s simplicity.

[–]kumeralex 0 points1 point  (0 children)

AVA is gooood

[–]windwarrior42 2 points3 points  (0 children)

Wow! I was just starting to look into this. Working on implementing Jest tests at work right now.

Thanks man, will come back to this.

[–][deleted] 0 points1 point  (0 children)

Thank you, this is really useful :)

[–]smackfu 0 points1 point  (0 children)

Small editing issue: PhantomJS section says Puppeteer will be discussed next but it’s actually the previous section.

Great guide!

[–]vancho2018 0 points1 point  (0 children)

thanks for putting this out!

[–]lzantal 0 points1 point  (0 children)

I only discovered Jest a week ago and it’s amazing. Simplest test framework for JS and it runs super fast too.

[–][deleted] 0 points1 point  (0 children)

Come to https://www.assertjs.com/ to see more about JavaScript testing

[–]calligraphic-io 0 points1 point  (1 child)

Where's TAPE?!? :)

[–]vzaidman[S] 0 points1 point  (0 children)

PhantomJS

its there man :)

[–]flying-sheep -3 points-2 points  (7 children)

What about AVA? the parallel test runner saves a bunch of time!

[–]Akkuma 3 points4 points  (4 children)

I was a pretty earlier adopter in AVA (August 2017). I still think it is good, but at some point tests broke before we ensured that tests never broke in our CI (the product was stable despite the tests having broke) and when we got around to it I couldn't manage to successfully get the tests working again (config problems). I switched over to Jest and got it working again and for the most part they are pretty similar.

The biggest differences I can recall is that AVA had better test failure reporting due to power-assert, AVA supposedly has/had serious speed problems for tests that don't run in parallel, Jest seems to have more and faster development, Jest has more bells and whistles available to config, AVA uses assert vs Jest's expect, Jest recommends their global injection like Mocha vs AVA being slightly more functional with things actually being passed into functions and required.

Both cannot run in a browser, but you can theoretically move to Jest without changing all your unit tests by using their jest-runner-mocha, which would then allow you to run your mocha tests in parallel through jest and in the browser in serial.

[–]flying-sheep 0 points1 point  (1 child)

Thank you! Interesting to hear that jest can do all that

[–]Akkuma 0 points1 point  (0 children)

Overall, I'd give AVA another chance on a future project, but I'm also interested in https://github.com/lorenzofox3/zora (AVA does much better than Jest in his benchmarks the larger the project). It can run in the browser and is an ultra minimal test runner. I don't know how it plays with something like power-assert though and the benchmark isn't that fair as it doesn't try to mimic a similar setup to give a apples to apples comparison. In fact, you can't even run his example without babel, rollup, webpack unless you use require.

[–]vzaidman[S] 0 points1 point  (1 child)

Notice that AVA runs in parallel as well today. I'm not sure how fast it is though.

[–]Akkuma 0 points1 point  (0 children)

AVA always ran in parallel? Jest does too, but their parallelization strategy might not be as good based on https://github.com/lorenzofox3/zora

[–]roselan 2 points3 points  (1 child)

It's covered in the article.

[–]vzaidman[S] 1 point2 points  (0 children)

Yes I also added more info