2

任何建议如何使用Sinonwith ava?当我跑步时avastub.called总是false

目标.js

const foo = () => { bar() }
const bar = () => { }

module.exports = { foo, bar }

目标.test.js

import test from 'ava';
import sinon from 'sinon';
import * as target from './target';

test('foo', t=>{
    const stub = sinon.stub(target, 'bar')    
    target.foo();
    t.true(stub.called)
})
4

0 回答 0