Need advice about which tool to choose?Ask the StackShare community!

AVA

110
204
+ 1
32
Mocha

8.5K
2.9K
+ 1
430
Add tool

AVA vs Mocha: What are the differences?

## Key Differences between AVA and Mocha

AVA and Mocha are both popular JavaScript testing frameworks, but they have some key differences that set them apart. 

1. **Concurrency**: AVA runs tests concurrently, allowing for faster test execution compared to Mocha, which runs tests sequentially. This can be beneficial for large test suites as it helps in reducing overall testing time.
2. **Syntax**: Mocha uses a simple and flexible syntax, making it easier for beginners to get started with testing. On the other hand, AVA uses a more opinionated syntax that enforces certain testing practices, providing a more structured approach to writing tests.
3. **Isolation**: AVA sandboxes each test file, running them in parallel to prevent any interference between tests. In contrast, Mocha runs all tests within the same process, potentially causing issues with test data leaking between tests.
4. **Installation**: Mocha requires additional setup and installation of assertion libraries like Chai, while AVA comes bundled with its own assertion library. This makes AVA a more lightweight and self-sufficient solution for testing.
5. **Asynchronous Testing**: AVA natively supports promises and async/await syntax for handling asynchronous operations, making it easier to write and maintain asynchronous tests. Mocha, on the other hand, may require additional setup or plugins to enable this functionality.
6. **Configuration**: Mocha provides more flexibility in configuration options, allowing users to customize test runners, reporters, and other settings. AVA, on the other hand, comes with a minimalistic configuration approach, which may be preferred by those looking for simplicity.

In Summary, AVA and Mocha differ in terms of concurrency, syntax, isolation, installation, asynchronous testing support, and configuration options.
Decisions about AVA and Mocha

We use Mocha for our FDA verification testing. It's integrated into Meteor, our upstream web application framework. We like how battle tested it is, its' syntax, its' options of reporters, and countless other features. Most everybody can agree on mocha, and that gets us half-way through our FDA verification and validation (V&V) testing strategy.

See more
Get Advice from developers at your company using StackShare Enterprise. Sign up for StackShare Enterprise.
Learn More
Pros of AVA
Pros of Mocha
  • 12
    Simple and fast
  • 6
    Parallel test running
  • 5
    Open source
  • 3
    Promise support
  • 3
    Test code Instrumenting
  • 2
    Babel integration
  • 1
    ESM Ready
  • 137
    Open source
  • 102
    Simple
  • 81
    Promise support
  • 48
    Flexible
  • 29
    Easy to add support for Generators
  • 12
    For browser and server testing
  • 7
    Curstom assertion libraries
  • 5
    Works with Karma
  • 3
    No other better tools
  • 1
    Simple setup
  • 1
    Works with saucelabs
  • 1
    Lots of tutorials and help online
  • 1
    Default reporter is nice, clean, and itemized
  • 1
    Works with BrowserStack
  • 1
    Simple integration testing

Sign up to add or upvote prosMake informed product decisions

Cons of AVA
Cons of Mocha
  • 1
    No built-in support for DOM
  • 1
    No source files compilation
  • 3
    Cannot test a promisified functions without assertion
  • 2
    No assertion count in results
  • 1
    Not as many reporter options as Jest

Sign up to add or upvote consMake informed product decisions

What is AVA?

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.

What is Mocha?

Mocha is a feature-rich JavaScript test framework running on node.js and the browser, making asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases.

Need advice about which tool to choose?Ask the StackShare community!

What companies use AVA?
What companies use Mocha?
See which teams inside your own company are using AVA or Mocha.
Sign up for StackShare EnterpriseLearn More

Sign up to get full access to all the companiesMake informed product decisions

What tools integrate with AVA?
What tools integrate with Mocha?
    No integrations found

    Sign up to get full access to all the tool integrationsMake informed product decisions

    Blog Posts

    JavaScriptGitHubNode.js+29
    14
    13459
    JavaScriptGitHubGit+33
    20
    2091
    What are some alternatives to AVA and Mocha?
    Jest
    Jest provides you with multiple layers on top of Jasmine.
    EVA
    Equipping you with hundreds of symbols and dozens or styles configurations, it makes sure the design stays consistent across all of your applications and platforms.
    JavaScript
    JavaScript is most known as the scripting language for Web pages, but used in many non-browser environments as well such as node.js or Apache CouchDB. It is a prototype-based, multi-paradigm scripting language that is dynamic,and supports object-oriented, imperative, and functional programming styles.
    Git
    Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
    GitHub
    GitHub is the best place to share code with friends, co-workers, classmates, and complete strangers. Over three million people use GitHub to build amazing things together.
    See all alternatives