rewire icon indicating copy to clipboard operation
rewire copied to clipboard

How to rewire if exported a function only

Open scaljeri opened this issue 8 years ago • 1 comments

Suppose you only export a function

export default function () {
    return Math.random();
}

Is it now possible to use rewire ?

For example, the following doesn't work

import rewire from 'rewire';
let bar = rewire('./bar');
bar.__set__(() => { .... });

Is this possible ?

scaljeri avatar Apr 08 '16 15:04 scaljeri

@scaljeri My guess is you'll have to wrap it in another service / module and rewire that. Maybe someone else will have an idea

Eli-Goldberg avatar Apr 12 '17 17:04 Eli-Goldberg