Guarantee: error disappears #

A guarantee property checks that something good eventually happens, within some time bound. Here is a property that checks that error messages disappear within five seconds.

import { extract, always, now, eventually } from "@antithesishq/bombadil";
export * from "@antithesishq/bombadil/browser/defaults";

const errorMessage = extract((state) => 
    state.document.body.querySelector(".error")?.textContent ?? null,
);

export const errorDisappears = always(
    now(() => errorMessage.current !== null).implies(
        eventually(() => errorMessage.current === null)
            .within(5, "seconds"),
    ),
);