wechat-miniprogram/miniprogram-simulate

使用插件,报错

Closed this issue · 1 comments

错误信息

invalid componentPath: /Users/issaclau/workspace/akc/live_weapp_sdk/src/components/goods-live/goods-playing/plugin:/liveRoomPlugin/live-room-play

不支持插件,我能理解,但是为什么要报错呢?

  1. 能不能直接忽略,这样我还可以测页面的其他部分
  2. 或者提供mock的方式,让业务可以mock插件的实现

目前直接报错导致页面根本无法测试了

可以 mock 掉组件的实现,通过 simulate.load({ template: '<slot />' }) 生成一个 mock 组件,然后在渲染测试组件的时候通过 usingComponents 注册将其 mock 掉即可。
具体可以参考 https://github.com/wechat-miniprogram/weui-miniprogram/blob/master/src/uploader/__test__/uploader.test.ts#L37 中如何在 mp-uploader 组件测试中将 mp-gallery 组件 mock