I'm using React Testing Library with react-select-event and with Jest. In my project, I have a <label>
that can have different text accordingly to select option is selected. I want to test that. I'm trying to invoke select change and then do the test on changed DOM.
import React from 'react'
import selectEvent from 'react-select-event'
import {render} from '@testing-library/react';
it('Should contain other text after certain select option is selected', async () => {
const {findByLabelText, getByText} = render(<Providers />);
const provider = await findByLabelText('Provider');
await selectEvent.select(provider, 'My provider');
const myLabel = getByText('Conditionaly new text');
});
In the end, the new label cannot be found. Is it possible to do tests on DOM changed by the tests itself?
Aucun commentaire:
Enregistrer un commentaire