From 805d4542bc5eac8c41ca779286f6b9944f695565 Mon Sep 17 00:00:00 2001 From: Kyle Gach Date: Tue, 2 Sep 2025 17:46:39 -0600 Subject: [PATCH] docs: address feedback - consistent tabs vs. spaces in snippet - add more Storybook details --- documentation/docs/07-misc/02-testing.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/documentation/docs/07-misc/02-testing.md b/documentation/docs/07-misc/02-testing.md index 468dbfa03f..d8115a35b4 100644 --- a/documentation/docs/07-misc/02-testing.md +++ b/documentation/docs/07-misc/02-testing.md @@ -287,25 +287,25 @@ You can create stories for component variations and test interactions with the [ ```svelte /// file: LoginForm.stories.svelte { + name="Filled Form" + play={async ({ args, canvas, userEvent }) => { // πŸ‘‡ Simulate a user filling out the form await userEvent.type(canvas.getByTestId('email'), 'email@provider.com'); await userEvent.type(canvas.getByTestId('password'), 'a-random-password'); @@ -316,12 +316,14 @@ You can create stories for component variations and test interactions with the [ // πŸ‘‡ Assert that the success message is shown await expect(canvas.getByText('You’re in!')).toBeInTheDocument(); - }} + }} /> ``` When you view that story or run that test in Storybook, you can see each step of the simulated behavior and the assertions made against the component. If anything goes wrong, you can step back-and-forth through the test to pinpoint exactly where the issue occurred. +To learn more about Storybook's mocking, accessibility testing, interactions debugging, and coverage tools, please see the [Storybook testing docs](https://storybook.js.org/docs/writing-tests?ref=svelte-docs&renderer=svelte). + ## E2E tests using Playwright E2E (short for 'end to end') tests allow you to test your full application through the eyes of the user. This section uses [Playwright](https://playwright.dev/) as an example, but you can also use other solutions like [Cypress](https://www.cypress.io/) or [NightwatchJS](https://nightwatchjs.org/).