1.0.2 • Published 7 years ago

preact-cli-power-assert v1.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

preact-cli-power-assert

Plugin for ⚛️ preact-cli to use power-assert assertions.

npm David license

Getting Started

Install it with npm:

npm i -D preact-cli-power-assert

or with yarn:

yarn add preact-cli-power-assert --dev

This will also install:

And include in your project by creating or adding to preact.config.js.

export default function customWebpackConfiguration(config, env, helpers) {
  // Will run only in test environment via process.env.NODE_ENV check
  require('preact-cli-power-assert')(config, env);
}

Example

Write your assertions as usual, assert API is converted to power-assert by Babel.

import assert from 'assert';

function add (a, b) {
    assert(!isNaN(a));
    assert.equal(typeof b, 'number');
    assert.ok(!isNaN(b));
    return a + b;
}

Related

See also preact-cli-unassert.

Thanks

Many thanks to Jason Miller for creating ⚛️ Preact, much of the related ecosystem and lots of useful stuff.

Heavily inspired by preact-cli-lodash from Sara Vieira.

License

MIT