export { ZandersComponent } from './ZandersComponent'
<ZandersComponent>Some content</ZandersComponent>
Created
March 27, 2024 16:22
-
-
Save mrmartineau/00bdd540bb499b71ccfdd0af826d063b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export { ZandersComponent } from './ZandersComponent' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.ZandersComponentWrapper { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Meta, StoryObj } from "@storybook/react"; | |
import { expect, within, screen } from "@storybook/test"; | |
import { ZandersComponent } from "../ZandersComponent"; | |
/** | |
* Info | |
* - https://storybook.js.org/docs/writing-stories/play-function#writing-stories-with-the-play-function | |
*/ | |
const meta: Meta<typeof ZandersComponent> = { | |
title: "2. Components/ZandersComponent", | |
component: ZandersComponent, | |
parameters: { | |
actions: { argTypesRegex: "^trigger.*" }, | |
// layout: "centered", | |
}, | |
args: {}, | |
}; | |
export default meta; | |
type Story = StoryObj<typeof ZandersComponent>; | |
export const Default: Story = { | |
args: { | |
children: "Some content", | |
}, | |
async play({ canvasElement }) { | |
// const canvas = within(canvasElement); | |
expect(screen.getByText("Some content")).toBeInTheDocument(); | |
}, | |
}; | |
export const AnotherStory: Story = { | |
args: { | |
children: "Some more content", | |
}, | |
async play({ canvasElement }) { | |
// const canvas = within(canvasElement); | |
expect(screen.getByText("Some more content")).toBeInTheDocument(); | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { describe, expect, test } from "vitest"; | |
import { render, screen } from "@testing-library/react"; | |
// import userEvent from "@testing-library/user-event"; | |
import { composeStories } from "@storybook/testing-react"; | |
import * as ZandersComponentStories from "../__stories__/ZandersComponent.stories"; | |
const { Default } = composeStories(ZandersComponentStories); | |
describe("ZandersComponent", () => { | |
test("renders the ZandersComponent component", async () => { | |
const { container } = render(<Default>Some content</Default>); | |
// @ts-expect-error we're using incompatible version of testing-react and | |
// Storybook which will be resolved when we update to React 18 | |
await Default.play({ canvasElement: container }); | |
expect(screen.getByText("Some content")).toBeInTheDocument(); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { type ComponentPropsWithoutRef } from "react"; | |
import styles from './styles.module.css' | |
export type ZandersComponentProps = {} & ComponentPropsWithoutRef<"div">; | |
export const ZandersComponent = ({ children, ...rest }: ZandersComponentProps) => { | |
return ( | |
<div | |
{...rest} | |
className={styles.ZandersComponentWrapper} | |
data-testid="ZandersComponent" | |
> | |
{children} | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment