JSPM

assert-helpers

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 856
  • Score
    100M100P100Q97589F
  • License

Common utilities and helpers to make testing assertions easier

Package Exports

  • assert-helpers

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (assert-helpers) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Assert Utilities & Helpers

Build Status NPM version NPM downloads Dependency Status Dev Dependency Status
Gratipay donate button Flattr donate button PayPayl donate button BitCoin donate button Wishlist browse button

Common utilities and helpers to make testing assertions easier

Usage

chaiHelpers = require('chai-helpers')

chaiHelpers.wait 1000, ->
    # this will execute after 1 second

chaiHelpers.throwUnexpected()
# ^ this will throw an error stating that the error was unexpected

chaiHelpers.expectEqual('actual results', 'expected results', 'the test name')
# ^ this will translate to expect('actual', 'test name').to.equal('expected')
# it will output the comparison if the comparison fails

chaiHelpers.expectDeepEqual('actual results', 'expected results', 'the test name')
# ^ this will translate to expect('actual', 'test name').to.deep.equal('expected')
# it will output the comparison if the comparison fails

chaiHelpers.returnViaCallback('result')
# ^ this will return a function that will return the result

chaiHelpers.completeViaCallback('result', 100)
# ^ this will return a function that will receive a completion callback as its first argument, that will call the competion callback with the result after the delay

chaiHelpers.returnErrorViaCallback('the error or error message')
# ^ this will return a function that will return the error

chaiHelpers.expectViaCallback('expected', 'result', 'arguments')
# ^ this will return a function that will compare it's received arguments with our expected arguments

chaiHelpers.expectError(theErrorWeReceived, 'the error we expect it to be', 'the test name')
# ^ this will check that the error we received is the error we expect
# it will output the comparison if the comparison fails

chaiHelpers.expectErrorViaCallback('the error we expect', anOptionalCompletionCallback)
# ^ this will return a function that will compare its received error (its first received argument) with the error we expect it to be
# it will output the comparison if the comparison fails
# it accepts an optional completion callback argument if you'd prefer not to throw the error or are doing an asynchronous test

History

Discover the change history by heading on over to the HISTORY.md file.

Contribute

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

Backers

Maintainers

These amazing people are maintaining this project:

Sponsors

No sponsors yet! Will you be the first?

Gratipay donate button Flattr donate button PayPayl donate button BitCoin donate button Wishlist browse button

Contributors

No contributors yet! Will you be the first? Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

License

Unless stated otherwise all works are:

and licensed under: