Giter VIP home page Giter VIP logo

aya's Introduction

Build Status Coverage

aya

aya

Just a wrapped tap, more fun.

Install

$ npm i -D aya

Usage

package.json

{
  "scripts": {
    "test": "aya test/index.js --coverage"
  }
}

test/index.js

const {test} = require('aya')

test.before(() => {
  // some setup
})

test('description', async t => {
  const result = await getResult()
  t.is(result, true)
})

And then

$ npm test

t.end() only in test.cb

Unlike tap, we should only use t.end() in test.cb.

test.cb('test result with callback', t => {
  getResult(result => {
    t.is(result, true)
    t.end()
  })
})

t.end() is NO MORE necessary for test

test('sync test', t => {
  const result = getSyncResult()
  t.is(result, true)
})

test('async test', async t => {
  const result = await getAsyncResult()
  t.is(result, true)

  // t.end() here is useless and has no effect.
})

Lifecycles

aya supports FOUR lifecycle methods which are listed below according to the executing sequence:

  • test.before(fn)
  • test.beforeEach(fn)
  • test.afterEach(fn)
  • test.after(fn)
// Both sync and async functions are supported
test.before(async t => {
  await startServer()

  // We could do assertions inside lifecycle methods
  t.is(await getServerPort(), 8080)
})

We could also define lifecycle methods by using setters:

test.before = async t => {
  await startServer()
  t.is(await getServerPort(), 8080)
}

Command Line

The command line interface of aya is exactly the same as tap.

For example, if we want to use aya with codecov

$ npm i -D aya codecov

package.json

{
  "scripts": {
    "test": "aya test/index.js --coverage",
    "posttest": "aya --coverage-report=html && codecov"
  }
}

License

MIT

aya's People

Contributors

kaelzhang avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aya's Issues

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.