can you please advise on how to test shoelace components with vitest

37 Views Asked by At

i have created a simple react component which contains an input field:

import SlInput from "@shoelace-style/dist/react/input/index.js";

const Select = () => {
return <SlInput data-testId="input" value="hello"></SlInput>
};

export default Select;

i am trying to test the component using vitest - here is my test case:

test("Test", () => {
  render(); const elem = screen.getByTestId("input"); 
  //expect(elem).toBeTruthy(); 
  expect((elem as any).value).toEqual("hello");
 });

the case which tests if the component exists is passing fine but when i try to test to component's value, i get the error:

AssertionError: expected '' to deeply equal 'hello'

- Expected
+ Received

- hello

can you please advise.

0

There are 0 best solutions below