附录 2:Testing Library 组件测试基础

import { render } from '@testing-library/react'
test('should show h1 title', () => {
// given
const comp = render(<App />)
// when
const result = comp.getByTestId('title').textContent
// then
expect(result).toBe('练功房前端脚手架')
})Query 查找元素
测试组件的交互行为
最后更新于