我有一个场景,需要在String.prototype上存根一个getter方法。在本例中,是由NPM模块colors定义的方法。it('should only apply colors if enable in the .ENV file', function () { console.log(stringGreyStub.called);上述测试的输出为:
FAKE!但是,
我刚刚把我的目录导入从import _ from 'lodash';更改为import debounce from 'lodash/debounce';
在我的测试中,我曾经有过sandbox.stub很明显,sandbox.stub(debounce).returnsArg(0);是行不通的。当只从一个模块导出一个函数时,不知道该做什么。