翻篇收录说明
翻篇网页快照

Test Results - shadcn/ui

https://ui.shadcn.com/docs/ai-elements/radix/test-results

最近抓取:2026-12-04 04:17:41(北京时间)

最近内容变化:2026-12-01 01:44:57(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Displays a test run by the agent, with its suites and failures.

正文摘录

SectionsIntroductionComponentsAI ElementsInstallationThemingCLITypesetSkillsRegistryChangelogComponentsAccordionAlertAlert DialogAspect RatioAttachmentAvatarBadgeBreadcrumbBubbleButtonButton GroupCalendarCardCarouselChartCheckboxCode BlockCollapsibleComboboxCommandContext MenuData TableDate PickerDialogDirectionDrawerDropdown MenuEmptyFieldHover CardInputInput GroupInput OTPItemKbdLabelMarkerMenubarMessageMessage ScrollerNative SelectNavigation MenuPaginationPopoverProgressQuestionnaireRadio GroupResizableScroll AreaSelectSeparatorSheetSidebarSkeletonSliderSonnerSpinnerSwitchTableTabsTextareaToastToggleToggle GroupTooltipTraceTypographyAI ElementsIntroductionChain of ThoughtChatCheckpointConfirmationContextFile TreeInline CitationMessageModel SelectorPlanPrompt InputQueueReasoningSourcesStack TraceSubagentSuggestionTaskTerminalTest ResultsToolGet StartedInstallationcomponents.jsonPackage ImportsThemingTypesetDark ModeCLIMonorepoSkillsJavaScriptFigmallms.txtLegacy Docs@shadcn/reactMessage ScrollerQuestionnaire@shadcn/helpersAI SDKTanStack AIFormsReact Hook FormTanStack FormFormischUtilitiesscroll-fadeshimmerRegistryIntroductionGetting StartedGitHub RegistriesRegistry DirectoryRegistry HealthExamplesNamespacesAuthenticationDynamic SearchMCP ServerOpen in v0FAQAPI Referenceregistry.jsonregistry-item.jsonTest ResultsCopy PagePreviousNextDisplays a test run by the agent, with its suites and failures.Base UIReact AriaRadix UIRun the checkout tests.Ran 5 tests, 1 failedcart.test.ts, 3 testspayment.test.ts, 2 tests, 1 failedcharges the saved cardretries a declined cardExpected 2 charge attempts, received 1 at Object.<anonymous> (src/payment.test.ts:58:22)One test failed. The payment client does not retry a declined card, so the second charge attempt never happens.ReplayCopy"use client" import { useChat } from "@ai-sdk/react"View Code Test Results is a test run by the agent. The summary line counts what passed and failed. Open it to see each suite, its tests, and the error for each failure. Test Results is built with Trace with a TraceCollapsible for the run and for each suite. Installation Test Results is built with the Trace and Code Block components. CommandManualpnpmnpmyarnbunpnpm dlx shadcn@latest add trace code-blockCopy Usage Copyimport { CodeBlock, CodeBlockContent } from "@/components/ui/code-block" import { Trace, TraceCollapsible, TraceCollapsibleContent, TraceCollapsibleTrigger, TraceIcon, TraceLine, TraceTitle, } from "@/components/ui/trace" Copy<Trace> <TraceCollapsible> <TraceCollapsibleTrigger> <TraceLine status="error"> <TraceIcon> <FlaskConicalIcon /> </TraceIcon> <TraceTitle>Ran 2 tests, 1 failed</TraceTitle> </TraceLine> </TraceCollapsibleTrigger> <TraceCollapsibleContent> <Trace> <TraceLine> <TraceIcon> <CheckIcon /> </TraceIcon> <TraceTitle>creates a user</TraceTitle> </TraceLine> <TraceCollapsible> <TraceCollapsibleTrigger> <TraceLine status="error"> <TraceIcon> <XIcon /> </TraceIcon> <TraceTitle>updates a user profile</TraceTitle> </TraceLine> </TraceCollapsibleTrigger> <TraceCollapsibleContent> <CodeBlock size="sm"> <CodeBlockContent wrap className="max-h-64"> Expected status 200, received 500 </CodeBlockContent> </CodeBlock> </TraceCollapsibleContent> </TraceCollapsible> </Trace> </TraceCollapsibleContent> </TraceCollapsible> </Trace> Suites Group tests by file. Each suite is a collapsible line with a Trace of its tests. Open the suites that have a failure. Ran 8 tests, 2 failed, 1 skippedauth.test.ts, 3 testsuser-api.test.ts, 3 tests, 1 failed, 1 skippedcreates a userupdates a user profileSkipped deletes a userdb.test.ts, 2 tests, 1 failedconnects to the databasetimes out a slow queryCopyimport { CheckIcon, CircleDashedIcon,View Code Copy<TraceCollapsible defaultOpen={failed > 0}> <TraceCollapsibleTrigger> <TraceLine status={failed > 0 ? "error" : undefined}> <TraceIcon> <FileCodeIcon /> </TraceIcon> <TraceTitle>user-api.test.ts, 14 tests, 2 failed</TraceTitle> </TraceLine> </TraceCollapsibleTrigger> <TraceCollapsibleContent> <Trace>…</Trace> </TraceCollapsibleContent> </TraceCollapsible> AI SDK Run the tests as a tool and render its output. The tool states map the same way as in Tool. Copyconst tests = part.output.suites.flatMap((suite) => suite.tests) const failed = tests.filter((test) => test.status === "failed").length return ( <TraceCollapsible defaultOpen={failed > 0}> <TraceCollapsibleTrigger> <TraceLine status={failed > 0 ? "error" : undefined}> <TraceIcon> <FlaskConicalIcon /> </TraceIcon> <TraceTitle> Ran {tests.length} tests{failed > 0 && `, ${failed} failed`} </TraceTitle> </TraceLine> </TraceCollapsibleTrigger> <TraceCollapsibleContent>…</TraceCollapsibleContent> </TraceCollapsible> ) Migrating from AI SDK Elements If you added Test Results from AI SDK Elements, your project has a components/ai-elements/test-results.tsx wrapper. Paste this prompt into your coding agent to rebuild it on Trace and Code Block. Every export keeps its name and props, so the code that uses it keeps working. PromptCopyMigrate components/ai-elements/test-results.tsx from AI SDK Elements to the shadcn/ui Trace and Code Block components. Keep every export, with the same name and props, so the code that imports it keeps working. Only change how each part renders. 1. Install the components: npx shadcn@latest add trace code-block 2. Read https://ui.shadcn.com/docs/ai-elements/radix/test-results.md and build Test Results the same way. 3. Rebuild each part: - Import CodeBlock and CodeBlockContent from @/components/ui/code-block, not from ./code-block. - TestResults renders a Trace with a TraceCollapsible. Keep summary. - TestResultsHeader renders a TraceCollapsibleTrigger with a TraceLine, and TestResultsSummary a TraceTitle with the counts, like "Ran 42 tests, 2 failed". Set status="error" when a test failed. - TestResultsContent renders a TraceCollapsibleContent with a Trace for the suites. - TestSuite renders a TraceCollapsible, open when it has a failure. TestSuiteName renders a TraceCollapsibleTrigger with a TraceLine, and TestSuiteContent a TraceCollapsibleContent with a Trace for the tests. - Test renders a TraceLine with a TraceTitle for its name. Set status="error" when it failed. - TestError renders a CodeBlock with size="sm", with TestErrorMessage and TestErrorStack in a CodeBlockContent. - Keep TestResultsDuration, TestResultsProgress, TestSuiteStats, TestName, TestDuration and TestStatus as they are. 4. Remove the imports the file no longer uses. 5. Run the type checker and fix any errors.Expand API Reference See Trace. TerminalTool On This PageInstallationUsageSuitesAI SDKMigrating from AI SDK ElementsAPI ReferenceDeploy your shadcn/ui app on VercelTrusted by OpenAI, Sonos, Adobe, and more.Vercel provides tools and infrastructure to deploy apps and features at scale.Deploy NowDeploy to Vercel