Socket
Book a DemoInstallSign in
Socket

ava-spec

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ava-spec

Drop-in BDD helpers for AVA test runner ๐ŸŒ 

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
399
23.15%
Maintainers
1
Weekly downloads
ย 
Created
Source

AVA Spec

Build Status

Installation

AVA Spec is meant to be installed next to AVA, so please follow its installation instructions first.

Then, install ava-spec as a development dependency:

$ npm install --save-dev ava-spec

Usage

First of all, you can use ava-spec as a drop-in for ava:

import test from 'ava-spec';

test('AVA Spec is 100% compatible with ava', t => {
  t.is(true, true);
});

Jasmine-like DSL is supported:

test.describe('AVA Spec', it => {
  it('can look almost like jasmine', t => {
    t.deepEqual([1, 2], [1, 2]);
  });

  it.todo('supports all chaining modifiers!');
});

Group names are optional, though:

test.serial.skip.group(test => {
  test('AVA Spec can be used to just group some tests', t => {
    t.not(true, false);
  });
});

You can also write cucumber-like scenarios:

test.feature('Cash withdrawal.', scenario => {
  scenario('Not enough money in ATM', t => {
    // Cucumber-like keywords are available
  });
});

Last but not least you can assign groups to variables:

const subject = test.describe('You');

subject('do not need to use callacks!', t => {
  t.is(2 + 2, 4);
});

Result:

  - AVA Spec can be used to just group some tests
  โœ” AVA Spec is 100% compatible with ava
  โœ” AVA Spec can look almost like jasmine
  - AVA Spec supports all chaining modifiers!
  โœ” Cash withdrawal. Not enough money in ATM
  โœ” You do not need to use callacks!

  4 tests passed
  1 test skipped
  1 test todo

API

AVA spec allows you to define test groups using 3 equivalent methods:

test.describe([title], implementation)

test.feature([title], implementation)

test.group([title], implementation)

title

Type: string

A group title.

implementation(ava)

Type: function

It is called by AVA Spec with modified AVA instance as so:

  • Group modifiers are applied to all tests inside it
  • Group title is prefixed to all test titles inside it

Team

Adam StankiewiczPlease help me!
Adam StankiewiczBecome co-author!

Keywords

test

FAQs

Package last updated on 18 Apr 2016

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