使用Chai,您可以创建一个间谍对象,如下所示:
chai.spy.object([ 'push', 'pop' ]);
Run Code Online (Sandbox Code Playgroud)
使用茉莉花,您可以使用:
jasmine.createSpyObj('tape', ['play', 'pause', 'stop', 'rewind']);
Run Code Online (Sandbox Code Playgroud)
什么是Jest等价物?
上下文:我目前正在将(打字稿)Jasmine测试迁移到(typescript)Jest.在这种情况下,迁移指南基本上没用:https://facebook.github.io/jest/docs/migration-guide.html与任何相对较新的技术一样,在这方面的文档中没有任何东西可以轻易找到.
jestjs ×1