iteration-test
v1.4.0
Published
Runs automated testing for a given function to be run iteratively.
Downloads
4
Maintainers
Readme
Runs automated testing for a given function to be run iteratively.
Install
npm install iteration-test
Usage
const TestSuite = require('iteration-test')
let testSuite = new TestSuite({
testFunction: payload => ({ output: payload.current + payload.previous }),
tests: [
{
name: 'Adds current and previous fields at each turn',
rounds: [
{ inputExpression: '{ current: 3, previous: 0 }', evaluateExpression: 'output == 3' },
{ inputExpression: '{ current: 4, previous: output }', evaluateExpression: 'output == 7' },
{ inputExpression: '{ current: 5, previous: output }', evaluateExpression: 'output == 11' }, // Fails
]
}
]
})
let results = await testSuite.run()
Sample results
{
"success": false,
"passed": 0,
"failed": 1,
"details": [
{
"name": "Adds current and previous fields at each turn",
"success": false,
"error": "Expression [output == 11] is false for obtained output {\"output\":12}"
}
]
}
## Run tests
```sh
npm run test
Author
👤 Marco Cardoso
- Github: @MarcoABCardoso
- LinkedIn: @marco-cardoso
Show your support
Give a ⭐️ if this project helped you!