I'm new to Cypress. I got the following error. assert expected <textarea.w-full.border-2.min-h-[100px].p-4> to have value "New message from user134", but the value was ' ' Any idea what the problem is?
This is the component that include the textarea
import { useRequest } from "@/context/requestContext";
const ChatUser = () => {
const { requestData, setRequestData} = useRequest();
return(
<textarea
className='w-full border-2 min-h-[100px] p-4'
value={requestData.text}
data-cy="userChat"
onChange={(e) => setRequestData({...requestData, text: e.target.value})}
>
</textarea>
)
}
export default ChatUser;
I imported this component in the chat.tsx and I'm trying to test whole chat.tsx and my chat.cy.tsx is like that;
import React from 'react'
import Chat from './index';
describe('<Chat />',() => {
it('mount', () => {
cy.mount(<Chat />);
});
it('user chat textarea should work', () => {
cy.mount(<Chat />);
const newText = 'New message from user134';
cy.get('[data-cy="userChat"]').type(newText);
cy.get('[data-cy="userChat"]').should('have.value', newText);
})
})