riot-testing-library
riot-testing-library
建立在 DOM 测试库 之上,通过添加用于处理 Riot.js 组件的 API 来扩展它。
- npm
- Yarn
npm install --save-dev riot-testing-library
yarn add --dev riot-testing-library
import render, {fireEvent} from 'riot-testing-library'
import TestTag from './test.tag'
test('should show count text when rendered', () => {
const {queryByTestId} = render(TestTag, {count: 10})
expect(queryByTestId('count').textContent).toBe('10')
})
test('should add count when click add button text', () => {
const {queryByTestId} = render(TestTag, {count: 1})
expect(queryByTestId('count').textContent).toBe('1')
fireEvent.click(queryByTestId('button'))
expect(queryByTestId('count').textContent).toBe('2')
})