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

AVA

110
204
+ 1
32
Jest

9.7K
4K
+ 1
175
Add tool

AVA vs Jest: What are the differences?

Introduction

In this article, we will discuss the key differences between AVA and Jest, two popular testing frameworks used for JavaScript applications. AVA and Jest offer similar functionalities but have some distinct features that set them apart.

  1. Test Execution: AVA runs tests in parallel by default, using separate Node.js processes for each test file. This allows for faster test execution, as multiple test files can be executed simultaneously. On the other hand, Jest runs tests serially by default, executing them one after the other. While this may result in slower test execution, it can be advantageous for debugging and isolating test failures.

  2. Configuration: AVA has a more minimalistic approach to configuration compared to Jest. It requires a minimal configuration to get started, making it easier to set up and use. Jest, on the other hand, provides a more extensive and flexible configuration system, allowing developers to customize various aspects of the testing environment.

  3. Mocking: Jest has built-in mocking capabilities, making it easier to create and manage mock modules, functions, and dependencies. It provides a simple API for creating mocks and allows for advanced mocking techniques such as mock functions and timers. AVA, on the other hand, does not have built-in mocking capabilities but can leverage external libraries for mocking if needed.

  4. Snapshot Testing: Jest includes snapshot testing functionality, which allows developers to capture and compare snapshots of rendered components. This provides an easy way to track changes in the component's output and detect unintended changes. AVA does not have built-in snapshot testing functionality, but developers can use external libraries or custom solutions for snapshot testing.

  5. Watch Mode: Jest provides a watch mode that automatically detects changes in source or test files and re-runs the affected tests. This is particularly useful during development, as it allows for quick iteration and feedback on code changes. AVA does not have a built-in watch mode but can be integrated with tools like nodemon to achieve similar functionality.

  6. Additional Features: Jest offers additional features such as code coverage reporting, built-in code transformers (like Babel and TypeScript), built-in matchers for assertions, and support for parallel test execution in a single process. AVA, on the other hand, focuses more on simplicity and minimalism, and does not provide these additional features out of the box.

In summary, AVA and Jest are both powerful testing frameworks for JavaScript applications, but they have some key differences. AVA emphasizes parallel test execution, minimalistic configuration, and simplicity, while Jest offers features like mocking, snapshot testing, extensive configuration, and other additional functionalities. The choice between AVA and Jest ultimately depends on the specific requirements and preferences of the development team.

Decisions about AVA and Jest
Shared insights
on
CypressCypressJestJest

As we all know testing is an important part of any application. To assist with our testing we are going to use both Cypress and Jest. We feel these tools complement each other and will help us get good coverage of our code. We will use Cypress for our end to end testing as we've found it quite user friendly. Jest will be used for our unit tests because we've seen how many larger companies use it with great success.

See more

Postman will be used to do integration testing with the backend API we create. It offers a clean interface to create many requests, and you can even organize these requests into collections. It helps to test the backend API first to make sure it's working before using it in the front-end. Jest can also be used for testing and is already embedded into React. Not only does it offer unit testing support in javascript, it can also do snapshot testing for the front-end to make sure components are rendering correctly. Enzyme is complementary to Jest and offers more functions such as shallow rendering. UnitTest will be used for Python testing as it is simple, has a lot of functionality and already built in with python. Sentry will be used for keeping track of errors as it is also easily integratable with Heroku because they offer it as an add-on. LogDNA will be used for tracking logs which are not errors and is also a Heroku add-on. Its good to have a separate service to record logs, monitor, track and even fix errors in real-time so our application can run more smoothly.

See more
Manage your open source components, licenses, and vulnerabilities
Learn More
Pros of AVA
Pros of Jest
  • 12
    Simple and fast
  • 6
    Parallel test running
  • 5
    Open source
  • 3
    Promise support
  • 3
    Test code Instrumenting
  • 2
    Babel integration
  • 1
    ESM Ready
  • 36
    Open source
  • 32
    Mock by default makes testing much simpler
  • 23
    Testing React Native Apps
  • 20
    Parallel test running
  • 16
    Fast
  • 13
    Bundled with JSDOM to enable DOM testing
  • 8
    Mock by default screws up your classes, breaking tests
  • 7
    Out of the box code coverage
  • 7
    Promise support
  • 6
    One stop shop for unit testing
  • 3
    Great documentation
  • 2
    Assert Library Included
  • 1
    Built in watch option with interactive filtering menu
  • 1
    Preset support
  • 0
    Can be used for BDD
  • 0
    Karma

Sign up to add or upvote prosMake informed product decisions

Cons of AVA
Cons of Jest
  • 1
    No built-in support for DOM
  • 1
    No source files compilation
  • 4
    Documentation
  • 4
    Ambiguous configuration
  • 3
    Difficult
  • 2
    Many bugs still not fixed months/years after reporting
  • 2
    Multiple error messages for same error
  • 2
    Difficult to run single test/describe/file
  • 2
    Ambiguous
  • 2
    Bugged
  • 1
    BeforeAll timing out makes all passing tests fail
  • 1
    Slow
  • 1
    Reporter is too general
  • 1
    Unstable
  • 1
    Bad docs
  • 1
    Still does't support .mjs files natively
  • 1
    Can't fail beforeAll to abort tests
  • 0
    Interaction with watch mode on terminal

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 Jest?

Jest provides you with multiple layers on top of Jasmine.

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

What companies use AVA?
What companies use Jest?
Manage your open source components, licenses, and vulnerabilities
Learn More

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

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

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

    Blog Posts

    What are some alternatives to AVA and Jest?
    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.
    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.
    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.
    Visual Studio Code
    Build and debug modern web and cloud applications. Code is free and available on your favorite platform - Linux, Mac OSX, and Windows.
    See all alternatives