test-results-errors.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use client";
  2. import {
  3. Test,
  4. TestError,
  5. TestErrorMessage,
  6. TestErrorStack,
  7. TestResults,
  8. TestResultsContent,
  9. TestResultsHeader,
  10. TestResultsSummary,
  11. TestSuite,
  12. TestSuiteContent,
  13. TestSuiteName,
  14. } from "@/components/ai-elements/test-results";
  15. const stackTrace = ` at Object.<anonymous> (/app/src/api.test.ts:45:12)
  16. at Module._compile (node:internal/modules/cjs/loader:1369:14)
  17. at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)`;
  18. const Example = () => (
  19. <TestResults
  20. summary={{
  21. duration: 130,
  22. failed: 1,
  23. passed: 1,
  24. skipped: 0,
  25. total: 2,
  26. }}
  27. >
  28. <TestResultsHeader>
  29. <TestResultsSummary />
  30. </TestResultsHeader>
  31. <TestResultsContent>
  32. <TestSuite defaultOpen name="API" status="failed">
  33. <TestSuiteName />
  34. <TestSuiteContent>
  35. <Test duration={45} name="should fetch data" status="passed" />
  36. <Test duration={85} name="should update" status="failed">
  37. <TestError>
  38. <TestErrorMessage>Expected 200, got 500</TestErrorMessage>
  39. <TestErrorStack>{stackTrace}</TestErrorStack>
  40. </TestError>
  41. </Test>
  42. </TestSuiteContent>
  43. </TestSuite>
  44. </TestResultsContent>
  45. </TestResults>
  46. );
  47. export default Example;