Skip to content

Latest commit

 

History

History
43 lines (38 loc) · 1.07 KB

README.md

File metadata and controls

43 lines (38 loc) · 1.07 KB

Assertio

Assertio is a tiny assertion library, similar to Node's built-in assert. It makes testing much easier by giving you lots of assertions you can run against your code.

Assertations

  • assert(value: boolean, msg?)
  • assertValue(value, predicate, msg?)
  • assertFn(value: () => boolean, msg?)
  • ensureArray(value, msg?)
  • ensureObject(value, msg?)
  • ensureString(value, msg?)
  • ensureNumber(value, msg?)
  • ensureBoolean(value, msg?)
  • ensureNonVoid(value, msg?)
  • ensureNonNull(value, msg?)
  • ensureNonNullable(value, msg?)
  • nonVoid(value, msg?)
  • nonNull(value, msg?)
  • nonNullable(value, msg?)
  • never(msg?)
  • neverValue(value, msg?)
  • castValue(value)
  • cast(value)
  • as(value)
  • maybe(value)

TypeScript transformer plugin

Assertio has a typescript transformer plugin to remove all assertations on production. See how to use typescript plugins https://github.com/cevek/ttypescript

tsconfig.json

{
    "compilerOptions": {
        // ...
        "plugins": [
            { "transform": "assertio/transform" },
        ]
    }
}