Hacker News new | ask | show | jobs
by andrew_ 1891 days ago
Ava (https://github.com/avajs/ava) gets too little love from the blogging machinery. It's a breeze to use with TS, faster than Jest (YMMV of course), and I love the snapshot output over any other snapshot producing unit test tool. Use with NYC for coverage is a breeze.
7 comments

Related: uvu[1] which I think is intended to be a barebones version of Ava. I like the idea of not having a big fragile graph of dependencies to be able to run some tests. Not sure if uvu is any good for Typescript though.

1: https://github.com/lukeed/uvu

I actually started with Ava for a new project because it did a few things better than Jest. But ended up switching away because of this issue: https://github.com/avajs/ava/issues/2385

Basically, if an assertion fails in the middle of an individual test, most test runners stop executing that test. Ava (by design) continues on with the rest of that test. This makes it harder to debug issues.

(This not be a problem for everyone. I'm only mentioning it because it was a deal-breaker for me and wish I knew that going in.)

I've never moved past tape, have had ava on the list of things to look into for a very long time but seem to always just `yarn add -D tape bogota` (bogota is a library that runs tape in parallel), any real concrete reasons to use ava over tape? the ava guide says this:

> Tape and tap are pretty good. AVA is highly inspired by their syntax. They too execute tests serially. Their default TAP output isn't very user-friendly though so you always end up using an external tap reporter.

Nicer looking test output and serial execution seem to be the issues here, but I actually like the serial execution bit because it lets you write some messier tests (some that re-use a local test DB let's say) before you straighten up and write shared-nothing test-suites that can run in isolation (spin up a DB container/make a db-per-test-suite/etc).

Came here to mention how slow and sometimes awkward ts-jest is. I'll have to try out Ava and the others. I think jest is a great asset over mocha/jasmine/sinon/chai but it gets awkward in the typescript realm. Also thinking about how since it really isn't type aware (especially for mocks) that it loses some points compared to the ecosystems like mockito, nsubstitute, etc.
I was surprised that every Jest+TypeScript guide says to use ts-jest. I already have my IDE, the TypeScript watcher, and ESLint parsing/compiling all the code! I don't want to add fourth one :-P

I ended up just pointing Jest at my build output folder and that works. There are a couple minor annoyances but whatever.

(I actually started with Ava because it more directly supports using the existing build output, but I ran into another issue and had to switch back to Jest: https://github.com/avajs/ava/issues/2385)

AVA is great, I use it on a few projects and even developed a simple HTTP record/replay add-on for it. I'd say it's good for smaller projects.

One huge benefit of Jest though is the built-in mocking, including module mocking. This stuff is BYO in AVA. Module mocks in particular can be quite annoying to set up, so it's really nice that Jest pulls them all together in one cohesive package.

It's been a while (4 years) since I used Ava. Back then, it was impossibly slow - something about running tests in parallel even though they don't have any blocking operations being a significant overhead. Any idea if that's changed?
Added, thanks.