Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ava

Package Overview
Dependencies
Maintainers
3
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ava

Testing can be a drag. AVA helps you get it done.

  • 2.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
192K
decreased by-33.4%
Maintainers
3
Weekly downloads
 
Created

What is ava?

AVA is a test runner for Node.js with a concise API, detailed error output, and process isolation that allows for fast and reliable testing. It supports asynchronous testing, and its design encourages writing tests that run concurrently.

What are ava's main functionalities?

Concurrent Test Execution

AVA runs tests concurrently, which can lead to faster test execution. The example shows two tests, one synchronous and one asynchronous, both of which will run concurrently.

const test = require('ava');

test('foo', t => {
    t.pass();
});

test('bar', async t => {
    const bar = Promise.resolve('bar');
    t.is(await bar, 'bar');
});

Snapshot Testing

AVA supports snapshot testing, which allows you to save the output of your tests and compare it to future test runs. This is useful for ensuring that your code's output remains consistent over time.

const test = require('ava');

test('snapshot', t => {
    const obj = {foo: 'bar'};
    t.snapshot(obj);
});

Power Assert

AVA uses power-assert to provide detailed assertion messages, making it easier to understand why a test failed. The example shows a failing test with a clear assertion message.

const test = require('ava');

test('power assert', t => {
    const x = 'foo';
    t.is(x, 'bar');
});

Test Isolation

AVA ensures that each test runs in isolation, preventing side effects from affecting other tests. The example shows how `t.context` can be used to set up data for each test.

const test = require('ava');

test.beforeEach(t => {
    t.context.data = {foo: 'bar'};
});

test('test 1', t => {
    t.context.data.foo = 'baz';
    t.is(t.context.data.foo, 'baz');
});

test('test 2', t => {
    t.is(t.context.data.foo, 'bar');
});

Other packages similar to ava

Keywords

FAQs

Package last updated on 16 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc