-
First time poster, please excuse any formatting errors. What package within Headless UI are you using? What version of that package are you using? What browser are you using? What testing libraries are you using? What's your component look like?
}; Whats your test look like? import configureMockStore from "redux-mock-store"; import { describe, expect } from "@jest/globals"; const mockStore = configureMockStore([thunk]); describe("RowsPicker ", () => {
}); Describe your issue I have a RowsPicker component that is a headlessui Listbox. During my test, I click on the listbox to open the list options. I successfully grab all 4 list items and attempt to click on the 2nd option. This is where my issue lies. Before clicking on the list option, the selected list option is the 1st option in the list. After attempting to click on the 2nd list option, the 1st list option remains selected. I am unsure whether the issue lies with the fireEvent.click or my testing code. Any help is appreciated :) What else have you tried? Thank you so much for reading! & thank you for creating this library! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Can be marked as solved. Will leave response here for a paper trail. Fortunately, it's an issue on my end and not with HeadlessUI! For anyone else who may come across the same situation: My issue lied with incorrect mocking of the
` |
Beta Was this translation helpful? Give feedback.
Can be marked as solved. Will leave response here for a paper trail.
Fortunately, it's an issue on my end and not with HeadlessUI!
For anyone else who may come across the same situation:
My issue lied with incorrect mocking of the
useState
hook when rendering and testing my component. The error I saw was a misleading result; the solution was to mock my component with a Wrapper and to treat said Wrapper as a parent where you define your useState hook and pass it to the child component, like so:`
const store = mockStore({
settingsSlice: {
newRowsPerPage: 5,
},
});