babel-plugin-transform-comment-to-assert
replace commented expressions with assert statements
Install
$ npm install --save babel-plugin-transform-comment-to-assert
Usage
{ return babelcode;}; //=> 'assert.deepEqual(1, 1);'
Objects:
//=> 'a = { a: 1 };assert.deepEqual(a, { a: 1 });'
Results of function calls:
//=> "assert.deepEqual((() => 'foo')(), 'bar');"
It also supports console.log
:
//=> "console.log('foo');assert.deepEqual('foo', 'bar');"
Throws:
;/*=>`const a = () => { throw new Error('fail');};assert.throws(() => a(), Error);`*/
;/*=>`const a = () => { throw new Error('fail');};assert.throws(() => a(), /fail/);`*/
License
MIT © Sigurd Fosseng