【发布时间】:2020-05-10 17:20:31
【问题描述】:
目前很少有关于堆栈溢出的问题出现此错误,但没有一个问题解释了存根axios 上的此错误。我从 sinonjs.org 获取了样板工作示例,并尝试模拟 axios。它抛出错误
TypeError: Attempted to wrap get which has been Wrapped
代码如下:
import Axios from 'axios';
var sandbox = require('sinon').createSandbox();
describe('axios.get method', function () {
beforeEach(function () {
// stub out the `axios` method
sandbox.stub(Axios, 'get');
});
afterEach(function () {
// completely restore all fakes created through the sandbox
sandbox.restore();
});
it('should be called once', function () {});
});
【问题讨论】: