Using Vitest to test React component that uses custom hook
I'm using Vitest to test a React component that uses a custom hook. The custom hook creates a column for MUI DataGridPro with a custom
renderCell
function that renders a button in the column. The hook accepts a void callback function that is used for the onClick
of the button. When the button is clicked, a modal should open up to display information based on the row. In prod and dev this works as expected, but I'm not sure how to test it. I want a test that will test the clicking of the button to ensure the Modal opens up. If I don't mock the hook, I get an error telling me renderEntryIconColumn
is not a function, but when I do mock it and debug the test, renderEntryIconColumn
is undefined. Below is the hook and component.
0 Replies