Aller au contenu principal

riot-testing-library

[Traduction Bêta Non Officielle]

Cette page a été traduite par PageTurner AI (bêta). Non approuvée officiellement par le projet. Vous avez trouvé une erreur ? Signaler un problème →

riot-testing-library s'appuie sur DOM Testing Library en ajoutant des API pour manipuler les composants Riot.js.

npm install --save-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')
})