【发布时间】:2019-11-15 08:01:01
【问题描述】:
我有一个 JSON 文件,我需要以下方式:
const things = require('./path/to/things);
我想在沙箱中存根这个文件,所以它总是返回给定的夹具。
const fixture = {
fake: "things"
}
const sandbox = sinon.createSandbox();
beforeEach(() => {
sandbox.stub(things).returns(fixture);
});
afterEach(() => {
sandbox.restore();
});
这会导致错误returns is not a function。我不确定如何使用沙箱存根 JSON。谁能帮帮我?
【问题讨论】: