Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TomerAberbach/pava
🚀 Parameterized tests for ava!
https://github.com/TomerAberbach/pava
ava avajs nodejs parameterized parameterized-tests parametric testing testing-library
Last synced: 3 months ago
JSON representation
🚀 Parameterized tests for ava!
- Host: GitHub
- URL: https://github.com/TomerAberbach/pava
- Owner: TomerAberbach
- License: apache-2.0
- Created: 2021-08-27T00:29:07.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-03T05:47:09.000Z (over 1 year ago)
- Last Synced: 2024-07-02T20:31:00.654Z (4 months ago)
- Topics: ava, avajs, nodejs, parameterized, parameterized-tests, parametric, testing, testing-library
- Language: JavaScript
- Homepage: https://npm.im/pava
- Size: 414 KB
- Stars: 8
- Watchers: 4
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- Contributing: contributing.md
- License: license
Awesome Lists containing this project
- awesome-ava - pava - Parameterized testing. (Packages)
README
pava## Install
```sh
$ npm i pava
```## Usage
```js
import test from 'ava'
import parameterized from 'pava'
import { mySerialize, myDeserialize, myMax } 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)
})// Destructure object literals to test functions with multiple parameters!
parameterized(
test,
`maximum of two integers`,
{
sameInteger: { first: 2, second: 2, expected: 2 },
twoPositive: { first: 2, second: 3, expected: 3 },
onePositiveOneNegative: { first: 2, second: -3, expected: 2 },
twoNegative: { first: -2, second: -3, expected: -2 },
},
(t, { first, second, expected }) => {
t.is(myMax(first, second), expected)
},
)// 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](https://github.com/TomerAberbach/pava/blob/main/src/index.d.ts)
for more documentation.## Contributing
Stars are always welcome!
For bugs and feature requests,
[please create an issue](https://github.com/TomerAberbach/pava/issues/new).For pull requests, please read the
[contributing guidelines](https://github.com/TomerAberbach/pava/blob/main/contributing.md).## License
[Apache 2.0](https://github.com/TomerAberbach/pava/blob/main/license)
This is not an official Google product.