Even though JavaScript is single-threaded, IO in Node.js can happen in parallel due to its async nature. AVA takes advantage of this and runs your tests concurrently, which is especially beneficial for IO heavy tests. In addition, test files are run in parallel as separate processes, giving you even better performance and an isolated environment for each test file. Switching from Mocha to AVA in Pageres brought the test time down from 31 sec to 11 sec. Having tests run concurrently forces you to write atomic tests, meaning tests don't depend on global state or the state of other tests, which is a great thing!

Recently switched all my mocha integration tests to ava and quite liked it, mostly for it's ability to only run the tests in the file you change on save while watching. The performance speed ups aren't typical, though, unless you have structured your tests exactly the same in mocha and ava. I was doing things like only creating the necessary user in the before callback and then using it for all my tests, since they ran serially anyways. In ava you can't do that so you have to create a user in the beforeEach callback, meaning now I create a user for every single test.

Don't get me wrong, I still love it, but my tests went from 20 seconds to 100 secs. They're atomic and I trust them even more, but if it didn't have the ability to run just the tests in the file you save out of the box, I might've given it up.



posted by forwardslash: 1269 days ago