testberry

Performance and benchmark testing framework

Usage no npm install needed!

<script type="module">
  import testberry from 'https://cdn.skypack.dev/testberry';
</script>

README

Testberry

Build Status

Testberry is a performance and benchmark testing framework for Node.js and Mocha

Installation

npm i testberry --save-dev

Usage

import testberry from 'testberry'
import inspect from 'inspect'

describe('Benchmark testing', () => {
  it('String starts with ', () => {
    let result

    // Calculate evaluation time
    testberry.test('.startsWith()', () => {
      result = 'foo'.startsWith('f')
    })

    // Check whether test has worked very well
    inspect(result).isTrue()

    // Next test
    testberry.test('.indexOf(0)', () => {
      result = 'foo'.indexOf(0) === 'f'
    })

    inspect(result).isTrue()

    // And a third one
    testberry.test('.test()', () => {
      result = /^f/.test('foo')
    })

    inspect(result).isTrue()
  })
})