Skip to content

Testing actions reliably

I’m using xstate to implement a login flow. I have a machine where the initialState invokes a Promise, and if it’s rejected it will redirect to a state that has an entry action. I would like to test that the action is called at the right time properly. machine.ts machine.spec.ts I managed to make …

.removeEventListener(); by name or reference?

Say you have simple: Does removeEventListener remove a registered listener for click events named clickHandler or does it remove a registered listener for click events referencing the very same function that clickHandler references? Here they say: The event listener to be removed is identified using a combina…

Code not accessing nextElementSibling correctly

I have a <div> in my HTML: In my JavaScript I have code to dynamically create new elements (a <button> and a <pre>)and add to the <div>: Then I also have the following JS code to make the ‘next’ <pre> collapsible (show/hide) when the preceding <button> element i…