1234567891011121314151617181920212223242526272829 |
- // const simulate = require('miniprogram-simulate')
- // test('components/diy-icongroup', () => {
- // const id = simulate.load('/components/diy-icongroup') // 此处必须传入绝对路径
- // const comp = simulate.render(id) // 渲染成自定义组件树实例
- // const parent = document.createElement('parent-wrapper') // 创建父亲节点
- // comp.attach(parent) // attach 到父亲节点上,此时会触发自定义组件的 attached 钩子
- // const view = comp.querySelector('.index') // 获取子组件 view
- // expect(view.dom.innerHTML).toBe('index.properties') // 测试渲染结果
- // expect(window.getComputedStyle(view.dom).color).toBe('green') // 测试渲染结果
- // })
- const path = require('path')
- const expect = require('chai').expect
- describe('component', () => {
- it ('should run successfully', () => {
- // 此处直接使用 simulate 或者 window.simulate 即可,不需要再做 require
- const id = simulate.load(path.resolve(__dirname, 'component/diy-icongroup'))
- const comp = simulate.render(id, {prop: 'index.test.properties'})
- comp.attach(document.body) // 挂载在 body 下面
- expect(simulate.match(comp.dom, '<wx-view class="main--index">index.test.properties</wx-view>')).to.equal(true)
- })
- })
|