Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 62x 18x 18x 9x 9x 4x 5x 4x 18x 62x | import * as React from "react"; import type { ComponentStoryCy } from "orphic-cypress"; import { Button } from "stories"; export default { component: Button, cyIncludeStories: [] }; export const WillFetch: ComponentStoryCy<typeof Button> = (args) => { const [label, setLabel] = React.useState("loading"); React.useEffect(() => { fetch("/api/label") .then((result) => { if (result.ok) return result.json(); throw new Error("Not Found!"); }) .then((result) => setLabel(result.data)) .catch((error) => setLabel(error.toString())); }, []); return <Button {...args} label={label} />; }; WillFetch.parameters = { mockData: [ { url: "/api/label", method: "GET", status: 200, response: { data: "Loaded" }, }, ], // story-code @skip-start docs: { description: { story: `External tests will need to manually call \`cy.intercept\` or \`mockToCyIntercept(Story.parameters.mockData)\``, }, }, // story-code @skip-end }; // story-code @end |