Giter VIP home page Giter VIP logo

ava-spec's Introduction

DEPRECATED Please use Jest which is more powerful than Ava and supports describe out of the box.

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

You still run tests with ava command. The only thing that changes are tests themselves.

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:

import {describe} from 'ava-spec';

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

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

Or write cucumber-like scenarios:

import {feature} from 'ava-spec';

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

Or just group tests together:

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

Last but not least you can pass groups around in fun ways:

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

subject('do not need to use callbacks!', 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 callbacks!

  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:

  1. Group modifiers are applied to all tests inside it
  2. Group title is prefixed to all test titles inside it

Caveats

Currently AVA Spec doesn't support per-group hooks.

Team

Adam Stankiewicz Please help me!
Adam Stankiewicz Become co-author!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.