power-assert-js/power-assert

Does instrumentor works only on `assert` variable naming exactly?

jl- opened this issue · 2 comments

jl- commented

The following works

import assert from 'assert';
function test () {
    assert(1 === 2);
}
and the instructed code is
import assert from 'power-assert';
function test() {
    var _rec1 = new _PowerAssertRecorder1();
    assert(_rec1._expr(_rec1._capt(1 === 2, 'arguments/0'), {
        content: 'assert(1 === 2)',
        filepath: 'examples/test.js',
        line: 4
    }));
}

The following doesn't work

import varNameOtherThanAssert from 'assert';
function test () {
    varNameOtherThanAssert(1 === 2);
}

source code transformed into

import varNameOtherThanAssert from 'power-assert';
function test() {
    varNameOtherThanAssert(1 === 2);
}

source code are transformed by instrumentor through babel right? is there some improvement could be make on the instrument side?

jl- commented

Figured out that customization is required here, desired patterns should be added. closed

jl- commented
// .babelrc
{
    "plugins": [
        ["babel-plugin-espower", {
            "embedAst": true,
            "patterns": [
                "t(value, [message])"
            ]
        }]
    ]
}