Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

pava

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pava

Parameterized tests for ava!

latest
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

pava

version CI minzip size
Parameterized tests for ava!

Install

$ npm i pava

Usage

import test from 'ava'
import parameterized from 'pava'
import { mySerialize, myDeserialize } from './my-code.js'

// Writing your test like this...
parameterized(
  test,
  `integer serializing and deserializing`,
  {
    zero: 0,
    negative: -4,
    positive: 5,
    large: 100000,
  },
  (t, integer) => {
    t.is(myDeserialize(mySerialize(integer)), integer)
  },
)

// Is the same as writing it like this!
test(`integer serializing and deserializing - zero`, t => {
  t.is(myDeserialize(mySerialize(0)), 0)
})
test(`integer serializing and deserializing - negative`, t => {
  t.is(myDeserialize(mySerialize(-4)), -4)
})
test(`integer serializing and deserializing - positive`, t => {
  t.is(myDeserialize(mySerialize(5)), 5)
})
test(`integer serializing and deserializing - large`, t => {
  t.is(myDeserialize(mySerialize(100000)), 100000)
})

// And writing your test like this...
parameterized(
  test,
  `integer serializing and deserializing`,
  [0, -4, 5, 100000],
  (t, integer) => {
    t.is(myDeserialize(mySerialize(integer)), integer)
  },
)

// Is the same as writing it like this!
// Note: the titles aren't as nice for large test case objects
test(`integer serializing and deserializing - 0`, t => {
  t.is(myDeserialize(mySerialize(0)), 0)
})
test(`integer serializing and deserializing - -4`, t => {
  t.is(myDeserialize(mySerialize(-4)), -4)
})
test(`integer serializing and deserializing - 5`, t => {
  t.is(myDeserialize(mySerialize(5)), 5)
})
test(`integer serializing and deserializing - 100000`, t => {
  t.is(myDeserialize(mySerialize(100000)), 100000)
})

// You can also use any ava test interface!
parameterized(test.serial /* ... */)
parameterized(test.failing /* ... */)
parameterized(test.only /* ... */)
parameterized(test.skip /* ... */)
parameterized(test.todo /* ... */)
// etc.

See the type definitions for more documentation.

Contributing

Stars are always welcome!

For bugs and feature requests, please create an issue.

For pull requests, please read the contributing guidelines.

License

Apache 2.0

This is not an official Google product.

Keywords

ava

FAQs

Package last updated on 12 Sep 2021

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