Skip to content

Improve render tests to catch console errors and UI error boundaries #142

@ushkinaz

Description

@ushkinaz

Summary

Automated tests in src/testRenderMods.ts and src/testRender.ts (and potentially other render tests) fail to detect when a component crashes and is caught by a <svelte:boundary>. Currently, a test will pass even if the page displays an "Error" heading, provided it doesn't contain specific strings like undefined. Additionally, Svelte's internal console.error logs for structural issues (like each_key_duplicate) do not trigger test failures.

Context

  • Test Code: src/testRenderMods.ts
  • Error Handling: src/Thing.svelte uses <svelte:boundary> which renders an .error block with "Error" text when a child component fails.
  • Svelte Runtime: Svelte 5 logs many critical rendering issues directly to console.error.

Impact

  • CI/CD Blindness: Regressions that cause certain items to fail rendering are not caught in CI if they trigger the error boundary or just log to the console.
  • False Positives: Tests pass while the UI is broken for the user.

Severity

High. This affects the reliability of the entire automated test suite.

Steps to reproduce

  1. Run pnpm vitest run src/__mod_tests__/mod.no_global_uniques.test.ts.
  2. Observe that the test passes despite the output showing Svelte error: each_key_duplicate.
  3. Manually verify that the component is rendered as an "Error" block via the Svelte boundary if you were to look at the DOM output.

Tech details

Two specific improvements are needed:

  1. Assertion for Error Boundary: The renderCase in testRenderMods.ts should explicitly check that the rendered output does NOT contain the "Error" text or specific error boundary markers.
  2. Console Error Interception: Configure the test environment (e.g., in src/test-setup.ts) to intercept console.error. Any call to console.error (especially those originating from Svelte's runtime) should fail the current test context.

Acceptance criteria

  • pnpm vitest run src/__mod_tests__/mod.no_global_uniques.test.ts (and any other test hitting a rendering crash) fails explicitly.
  • The failure message clearly indicates if it's due to a console.error or hitting an UI error boundary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions