@sh32my/test

Super simple test framework.

Usage no npm install needed!

<script type="module">
  import sh32myTest from 'https://cdn.skypack.dev/@sh32my/test';
</script>

README

@sh32my/test

Super simple asynchronous test framework npm package.

Installing the package

Install the package from npm

npm i @sh32my/test

Using the package in a test script

An example of all methods

var MyClass = {

  myMethod: function () {
    return true
  },

  error: function () {
    throw new Error('MY_ERROR')
  }

}

var test = require('@sh32my/test')

test.file('filename goes here', function () {

  test.method('MyClass.myMethod()', function () {

    test.that('it returns true', function (done) {
      if (MyClass.myMethod() !== true) throw new Error('myMethod does not return true');
      else done()
    })

  })

  test.method('MyClass.error()', function () {

    test.error('MY_ERROR', 'is thrown on call', function (done) {
      MyClass.error()
      done()
    })

  })

})

This will produce the following output.


********************************************************************************
*
*  filename goes here
*
********************************************************************************


  MyClass.myMethod()

    ✓ it returns true


  MyClass.error()

    ✓ MY_ERROR is thrown on call


  RESULTS:  2 tests
            2 passed

Running a test script

To run test file just run using node

node my-test-file.js

Authors

License

This project is licensed under the MIT License.