Or, by visual testing a story, that same test looks like this.
Not only is it shorter, but it validates every visible thing on the page, not just what you explicitly check for. 🎉
ALT Screenshot of ShoppingCartMenu.stories.js file, containing the code:
import { ShoppingCartMenu } from './ShoppingCartMenu'
export default { component: ShoppingCartMenu };
export const WithItems = {
args: {
cartItems: [ /* items */ ],
totalPrice: 1200
},
play: async ({ canvasElement }) => {
const checkout = await findByRole(canvasElement, 'button');
await expect(checkout).not.toBeDisabled();
},
}