Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试模拟 npm uniqid 库以进行反应单元测试。我已将此 uniqid 用于复选框。这是用于组件渲染测试。
你可以像这样模拟它:
jest.mock('uniqid', ()=>(i)=> i + 'someUniqId')
或者如果您使用其他功能之一
jest.mock('uniqid', () = > ({ process: (i) => i + 'someProcess, time: (i) => i + ' someTime, }))