| 123456789101112131415161718192021222324252627 |
- import TestUtils from '@tarojs/test-utils-react'
- import React from 'react'
- const testUtils = new TestUtils()
- // 简单的测试组件
- const TestComponent = () => {
- return (
- <view className="test-component">
- <text className="btn">点击我</text>
- </view>
- )
- }
- describe('Taro Test Utils Example', () => {
- it('应该正确渲染组件', async () => {
- await testUtils.mount(TestComponent)
- const btn = await testUtils.queries.waitForQuerySelector('.btn')
- await testUtils.act(() => {
- testUtils.fireEvent.click(btn)
- })
- expect(testUtils.html()).toMatchSnapshot()
- })
- })
|