Test Results
Displays a test run by the agent, with its suites and failures.
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import { For, createMemo } from "solid-js"
import {
useDemoChat,
type UIDataTypes,
type UIMessage,
createChat,
getMessageText
} from "~/lib/ai-demo-chat"
import { Bubble, BubbleContent } from "~/components/ui/bubble"
import { Button } from "~/components/ui/button"
import { CodeBlock, CodeBlockContent } from "~/components/ui/code-block"
import { Message, MessageContent } from "~/components/ui/message"
import {
Trace,
TraceCollapsible,
TraceCollapsibleContent,
TraceCollapsibleTrigger,
TraceIcon,
TraceLine,
TraceTitle
} from "~/components/ui/trace"
type Test = {
name: string
status: "passed" | "failed" | "skipped"
error?: string
}
type ChatMessage = UIMessage<
unknown,
UIDataTypes,
{
runTests: {
input: { command: string }
output: { suites: { name: string; tests: Test[] }[] }
}
}
>
type ToolPart = Extract<ChatMessage["parts"][number], { type: "tool-runTests" }>
const chat = createChat<ChatMessage>()
.user("Run the checkout tests.")
.assistant(({ writer }) => {
writer
.tool("runTests", { input: { command: "pnpm test checkout" } })
.sleep(1500)
.output({
suites: [
{
name: "cart.test.ts",
tests: [
{ name: "adds an item", status: "passed" },
{ name: "removes an item", status: "passed" },
{ name: "applies a discount code", status: "passed" }
]
},
{
name: "payment.test.ts",
tests: [
{ name: "charges the saved card", status: "passed" },
{
name: "retries a declined card",
status: "failed",
error: `Expected 2 charge attempts, received 1
at Object.<anonymous> (src/payment.test.ts:58:22)`
}
]
}
]
})
writer.text(
"One test failed. The payment client does not retry a declined card, so the second charge attempt never happens."
)
})
const transcript = chat.get()
const [question] = chat.get(1)
const transport = chat.transport({ delayMs: 20 })
function countTests(tests: Test[]) {
return {
total: tests.length,
failed: tests.filter((test) => test.status === "failed").length,
skipped: tests.filter((test) => test.status === "skipped").length
}
}
function formatCounts({
total,
failed,
skipped
}: ReturnType<typeof countTests>) {
return [
`${total} tests`,
failed > 0 && `${failed} failed`,
skipped > 0 && `${skipped} skipped`
]
.filter(Boolean)
.join(", ")
}
function TestRow(componentProps: { test: Test }) {
const content = createMemo(() => {
const { test } = componentProps
if (test.status === "failed") {
return (
<TraceCollapsible defaultOpen>
<TraceCollapsibleTrigger>
<TraceLine status="error">
<TraceIcon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M18 6 6 18" />
<path d="m6 6 12 12" />
</svg>
</TraceIcon>
<TraceTitle>{test.name}</TraceTitle>
</TraceLine>
</TraceCollapsibleTrigger>
<TraceCollapsibleContent>
<CodeBlock size="sm">
<CodeBlockContent wrap class="max-h-64">
{test.error}
</CodeBlockContent>
</CodeBlock>
</TraceCollapsibleContent>
</TraceCollapsible>
)
}
return (
<TraceLine>
<TraceIcon>
{test.status === "skipped" ? (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M10.1 2.182a10 10 0 0 1 3.8 0" />
<path d="M13.9 21.818a10 10 0 0 1-3.8 0" />
<path d="M17.609 3.721a10 10 0 0 1 2.69 2.7" />
<path d="M2.182 13.9a10 10 0 0 1 0-3.8" />
<path d="M20.279 17.609a10 10 0 0 1-2.7 2.69" />
<path d="M21.818 10.1a10 10 0 0 1 0 3.8" />
<path d="M3.721 6.391a10 10 0 0 1 2.7-2.69" />
<path d="M6.391 20.279a10 10 0 0 1-2.69-2.7" />
</svg>
) : (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M20 6 9 17l-5-5" />
</svg>
)}
</TraceIcon>
<TraceTitle>
{test.status === "skipped" ? `Skipped ${test.name}` : test.name}
</TraceTitle>
</TraceLine>
)
})
return <>{content()}</>
}
function TestResultsRow(componentProps: {
part: ToolPart
streaming: boolean
}) {
const content = createMemo(() => {
const { part, streaming } = componentProps
const command = part.input?.command
if (part.state !== "output-available") {
const running = streaming && part.state !== "output-error"
return (
<TraceLine status={running ? "running" : "error"}>
<TraceIcon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2" />
<path d="M6.453 15h11.094" />
<path d="M8.5 2h7" />
</svg>
</TraceIcon>
<TraceTitle>
{running ? "Running" : "Failed to run"} {command}
</TraceTitle>
</TraceLine>
)
}
const { suites } = part.output
const summary = countTests(suites.flatMap((suite) => suite.tests))
return (
<TraceCollapsible defaultOpen={summary.failed > 0}>
<TraceCollapsibleTrigger>
<TraceLine status={summary.failed > 0 ? "error" : undefined}>
<TraceIcon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2" />
<path d="M6.453 15h11.094" />
<path d="M8.5 2h7" />
</svg>
</TraceIcon>
<TraceTitle>Ran {formatCounts(summary)}</TraceTitle>
</TraceLine>
</TraceCollapsibleTrigger>
<TraceCollapsibleContent>
<Trace>
{
<For each={suites}>
{(suite) => {
const content = createMemo(() => {
const counts = countTests(suite.tests)
return (
<TraceCollapsible defaultOpen={counts.failed > 0}>
<TraceCollapsibleTrigger>
<TraceLine
status={counts.failed > 0 ? "error" : undefined}
>
<TraceIcon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" />
<path d="M14 2v5a1 1 0 0 0 1 1h5" />
<path d="M10 12.5 8 15l2 2.5" />
<path d="m14 12.5 2 2.5-2 2.5" />
</svg>
</TraceIcon>
<TraceTitle>
{suite.name}, {formatCounts(counts)}
</TraceTitle>
</TraceLine>
</TraceCollapsibleTrigger>
<TraceCollapsibleContent>
<Trace>
{
<For each={suite.tests}>
{(test) => <TestRow test={test} />}
</For>
}
</Trace>
</TraceCollapsibleContent>
</TraceCollapsible>
)
})
return <>{content()}</>
}}
</For>
}
</Trace>
</TraceCollapsibleContent>
</TraceCollapsible>
)
})
return <>{content()}</>
}
export default function TestResultsDemo() {
const { messages, sendMessage, setMessages, status } = useDemoChat({
messages: transcript,
transport
})
const busy = () => status() === "submitted" || status() === "streaming"
return (
<div class="flex min-h-72 w-full max-w-sm flex-col gap-4 py-6 text-sm">
{
<For each={messages()}>
{(message) => {
const content = createMemo(() => {
if (message.role === "user") {
return (
<Message align="end">
<MessageContent>
<Bubble align="end" variant="muted">
<BubbleContent>{getMessageText(message)}</BubbleContent>
</Bubble>
</MessageContent>
</Message>
)
}
const streaming = busy() && message === messages().at(-1)
const tools = message.parts.filter(
(part) => part.type === "tool-runTests"
)
const text = getMessageText(message)
return (
<Message>
<MessageContent class="gap-4">
{tools.length > 0 && (
<Trace>
{
<For each={tools}>
{(part) => (
<TestResultsRow
part={part}
streaming={streaming}
/>
)}
</For>
}
</Trace>
)}
{text && <p>{text}</p>}
</MessageContent>
</Message>
)
})
return <>{content()}</>
}}
</For>
}
{!busy() && (
<Button
variant="outline"
size="sm"
class="mt-auto self-start"
onClick={() => {
setMessages([])
sendMessage(question)
}}
>
Replay
</Button>
)}
</div>
)
}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.
Install the required Solid UI dependencies:
Copy and paste the following code into your project.
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import type { ComponentProps, JSX } from "@solidjs/web"
import { merge, omit } from "solid-js"
import { cn } from "~/lib/utils"
import {
Collapsible,
CollapsibleContent,
CollapsibleTrigger
} from "~/components/ui/collapsible"
export function Trace(
props: Omit<ComponentProps<"div">, "class"> & { class?: string }
) {
return (
<div
{...props}
data-slot="trace"
class={cn(
"gap-2 *:has-[>[data-slot=trace-line]]:rounded-md *:has-[>[data-slot=trace-line]]:focus-visible:ring-3 *:has-[>[data-slot=trace-line]]:focus-visible:ring-ring/50 flex w-full min-w-0 flex-col *:has-[>[data-slot=trace-line]]:flex *:has-[>[data-slot=trace-line]]:w-fit *:has-[>[data-slot=trace-line]]:max-w-full *:has-[>[data-slot=trace-line]]:min-w-0 *:has-[>[data-slot=trace-line]]:text-left *:has-[>[data-slot=trace-line]]:outline-none",
props.class
)}
/>
)
}
export function TraceLine(
props: Omit<ComponentProps<"span">, "class"> & {
class?: string
status?: "running" | "error" | "pending" | undefined
}
) {
const rest = omit(props, "class", "status")
return (
<span
{...rest}
data-slot="trace-line"
data-status={props.status ?? undefined}
class={cn(
"gap-2 text-sm flex w-fit max-w-full min-w-0 items-center text-muted-foreground transition-colors in-[a,button]:cursor-pointer in-[a:hover,button:hover]:text-foreground data-[status=error]:text-destructive data-[status=error]:in-[a:hover,button:hover]:text-destructive data-[status=pending]:opacity-60 data-[status=running]:*:data-[slot=trace-title]:shimmer",
props.class
)}
/>
)
}
export function TraceIcon(
props: Omit<ComponentProps<"span">, "class"> & { class?: string }
) {
return (
<span
{...props}
data-slot="trace-icon"
class={cn(
"size-4 [&_svg:not([class*='size-'])]:size-4 [[data-slot=trace-title]~&]:-ml-1 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none",
props.class
)}
/>
)
}
export function TraceTitle(
props: Omit<ComponentProps<"span">, "class"> & { class?: string }
) {
return (
<span
{...props}
data-slot="trace-title"
class={cn(
"min-w-0 truncate motion-reduce:shimmer-none",
props.class
)}
/>
)
}
export function TraceDescription(
props: Omit<ComponentProps<"span">, "class"> & { class?: string }
) {
return (
<span
{...props}
data-slot="trace-description"
class={cn(
"shrink-0 text-muted-foreground/70 tabular-nums",
props.class
)}
/>
)
}
export function TraceCollapsible(props: ComponentProps<typeof Collapsible>) {
const rest = omit(props, "class", "render")
return (
<Collapsible
{...rest}
class={cn(
"flex w-full min-w-0 flex-col",
props.class
)}
render={(part, state) => {
const forwarded = merge(part, { "data-slot": "trace-collapsible" })
return props.render ? (
props.render(forwarded, state)
) : (
<div {...forwarded} />
)
}}
/>
)
}
export function TraceCollapsibleTrigger(
props: ComponentProps<typeof CollapsibleTrigger>
) {
const rest = omit(props, "class", "children", "render")
return (
<CollapsibleTrigger
{...rest}
class={cn(
"gap-1 rounded-md focus-visible:ring-3 focus-visible:ring-ring/50 group/trace-collapsible-trigger flex w-fit max-w-full min-w-0 cursor-pointer items-center text-left text-muted-foreground transition-colors outline-none hover:text-foreground has-[[data-slot=trace-line][data-status=error]]:text-destructive",
props.class
)}
render={(part, state) => {
const forwarded = merge(part, {
"data-slot": "trace-collapsible-trigger"
})
return props.render ? (
props.render(forwarded, state)
) : (
<button {...forwarded} />
)
}}
>
{props.children}
<TraceIcon class="transition-transform group-aria-expanded/trace-collapsible-trigger:rotate-90">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="m9 18 6-6-6-6" />
</svg>
</TraceIcon>
</CollapsibleTrigger>
)
}
export function TraceCollapsibleContent(
props: Omit<ComponentProps<typeof CollapsibleContent>, "children"> & {
children?: JSX.Element
}
) {
const rest = omit(props, "class", "children", "render")
return (
<CollapsibleContent
{...rest}
class="duration-200 h-(--collapsible-panel-height) min-w-0 overflow-hidden transition-[height] data-ending-style:h-0 data-starting-style:h-0"
render={(part, state) => {
const forwarded = merge(part, {
"data-slot": "trace-collapsible-content"
})
return props.render ? (
props.render(forwarded, state)
) : (
<div {...forwarded} />
)
}}
>
<div
data-slot="trace-collapsible-content-inner"
class={cn(
"mt-2 mb-1 ml-[calc(--spacing(2)-1px)] border-l pr-1 pl-4 leading-relaxed min-w-0 wrap-break-word text-muted-foreground",
props.class
)}
>
{props.children}
</div>
</CollapsibleContent>
)
}Update the import paths to match your project setup.
Usage
import { CodeBlock, CodeBlockContent } from "~/components/ui/code-block"
import {
Trace,
TraceCollapsible,
TraceCollapsibleContent,
TraceCollapsibleTrigger,
TraceIcon,
TraceLine,
TraceTitle
} from "~/components/ui/trace"<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 class="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.
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import { For, createMemo } from "solid-js"
import { CodeBlock, CodeBlockContent } from "~/components/ui/code-block"
import {
Trace,
TraceCollapsible,
TraceCollapsibleContent,
TraceCollapsibleTrigger,
TraceIcon,
TraceLine,
TraceTitle
} from "~/components/ui/trace"
type Test = {
name: string
status: "passed" | "failed" | "skipped"
error?: string
}
const suites: { name: string; tests: Test[] }[] = [
{
name: "auth.test.ts",
tests: [
{ name: "logs in with valid credentials", status: "passed" },
{ name: "rejects an invalid password", status: "passed" },
{ name: "refreshes an expired token", status: "passed" }
]
},
{
name: "user-api.test.ts",
tests: [
{ name: "creates a user", status: "passed" },
{
name: "updates a user profile",
status: "failed",
error: `Expected status 200, received 500
at Object.<anonymous> (src/user-api.test.ts:45:12)`
},
{ name: "deletes a user", status: "skipped" }
]
},
{
name: "db.test.ts",
tests: [
{ name: "connects to the database", status: "passed" },
{
name: "times out a slow query",
status: "failed",
error: `Exceeded timeout of 5000 ms for a test.
at Object.<anonymous> (src/db.test.ts:22:3)`
}
]
}
]
function countTests(tests: Test[]) {
return {
total: tests.length,
failed: tests.filter((test) => test.status === "failed").length,
skipped: tests.filter((test) => test.status === "skipped").length
}
}
function formatCounts({
total,
failed,
skipped
}: ReturnType<typeof countTests>) {
return [
`${total} tests`,
failed > 0 && `${failed} failed`,
skipped > 0 && `${skipped} skipped`
]
.filter(Boolean)
.join(", ")
}
function TestRow(componentProps: { test: Test }) {
const content = createMemo(() => {
const { test } = componentProps
if (test.status === "failed") {
return (
<TraceCollapsible>
<TraceCollapsibleTrigger>
<TraceLine status="error">
<TraceIcon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M18 6 6 18" />
<path d="m6 6 12 12" />
</svg>
</TraceIcon>
<TraceTitle>{test.name}</TraceTitle>
</TraceLine>
</TraceCollapsibleTrigger>
<TraceCollapsibleContent>
<CodeBlock size="sm">
<CodeBlockContent wrap class="max-h-64">
{test.error}
</CodeBlockContent>
</CodeBlock>
</TraceCollapsibleContent>
</TraceCollapsible>
)
}
return (
<TraceLine>
<TraceIcon>
{test.status === "skipped" ? (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M10.1 2.182a10 10 0 0 1 3.8 0" />
<path d="M13.9 21.818a10 10 0 0 1-3.8 0" />
<path d="M17.609 3.721a10 10 0 0 1 2.69 2.7" />
<path d="M2.182 13.9a10 10 0 0 1 0-3.8" />
<path d="M20.279 17.609a10 10 0 0 1-2.7 2.69" />
<path d="M21.818 10.1a10 10 0 0 1 0 3.8" />
<path d="M3.721 6.391a10 10 0 0 1 2.7-2.69" />
<path d="M6.391 20.279a10 10 0 0 1-2.69-2.7" />
</svg>
) : (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M20 6 9 17l-5-5" />
</svg>
)}
</TraceIcon>
<TraceTitle>
{test.status === "skipped" ? `Skipped ${test.name}` : test.name}
</TraceTitle>
</TraceLine>
)
})
return <>{content()}</>
}
export default function TestResultsSuites() {
const summary = countTests(suites.flatMap((suite) => suite.tests))
return (
<Trace class="max-w-sm">
<TraceCollapsible defaultOpen>
<TraceCollapsibleTrigger>
<TraceLine status={summary.failed > 0 ? "error" : undefined}>
<TraceIcon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2" />
<path d="M6.453 15h11.094" />
<path d="M8.5 2h7" />
</svg>
</TraceIcon>
<TraceTitle>Ran {formatCounts(summary)}</TraceTitle>
</TraceLine>
</TraceCollapsibleTrigger>
<TraceCollapsibleContent>
<Trace>
{
<For each={suites}>
{(suite) => {
const content = createMemo(() => {
const counts = countTests(suite.tests)
return (
<TraceCollapsible defaultOpen={counts.failed > 0}>
<TraceCollapsibleTrigger>
<TraceLine
status={counts.failed > 0 ? "error" : undefined}
>
<TraceIcon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" />
<path d="M14 2v5a1 1 0 0 0 1 1h5" />
<path d="M10 12.5 8 15l2 2.5" />
<path d="m14 12.5 2 2.5-2 2.5" />
</svg>
</TraceIcon>
<TraceTitle>
{suite.name}, {formatCounts(counts)}
</TraceTitle>
</TraceLine>
</TraceCollapsibleTrigger>
<TraceCollapsibleContent>
<Trace>
{
<For each={suite.tests}>
{(test) => <TestRow test={test} />}
</For>
}
</Trace>
</TraceCollapsibleContent>
</TraceCollapsible>
)
})
return <>{content()}</>
}}
</For>
}
</Trace>
</TraceCollapsibleContent>
</TraceCollapsible>
</Trace>
)
}<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.
const 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.
Migrate components/ai-elements/test-results.tsx from AI SDK Elements to the Solid 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 solidui-cli@latest add trace code-block
2. Read https://www.solid-ui.com/docs/ai-elements/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.API Reference
See Trace.