miniprogram-simulate
miniprogram-simulate copied to clipboard
小程序自定义组件测试工具集
```js // child.js Component({ options: { virtualHost: true, } }) ``` ```js const id = simulate.load({ template: ``, }) const comp = simulate.render(id); comp.attach(document.createElement('parent-wrapper')); const $search = comp.querySelector('.son'); // undefined...
安装pretty-format@26 后解决该问题,但最新版的pretty-format会报错
在组件中有以下代码: pageLifetimes: { hide() { this.setData({ showDialog: false }); }, }, 在unit test中使用 comp.triggerPageLifeTime('hide');运行test后,得到TypeError: comp.triggerPageLifesTime is not a function的报错,unit test未通过。
Cannot read property 'createElement' of null ----------------------------------------------------------------- ./node_modules/miniprogram-exparser/exparser.min.js)
这是测试文案 ---------- u-icon 组件没有渲染