iteration-test

Runs automated testing for a given function to be run iteratively.

Usage no npm install needed!

<script type="module">
  import iterationTest from 'https://cdn.skypack.dev/iteration-test';
</script>

README

iteration-test

Version License: ISC Coverage Status Node.js CI

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

Show your support

Give a ⭐️ if this project helped you!