Files
ComfyUI_frontend/tests-ui
Christian Byrne 90bf8dc74a [refactor] Move pure functions from layout store to separate modules so they can be tested (and add tests) (#5462)
* refactor layout store utils

* [refactor] use nullish coalescing in getOr helper - addresses @DrJKL's suggestion

Replaces manual undefined/null checks with more concise ?? operator
for cleaner code that achieves the same functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [refactor] improve Y.Map typing for better type safety - addresses @DrJKL's typing suggestions

- Use Y.Map<NodeLayout[keyof NodeLayout]> instead of Y.Map<unknown>
- Provides compile-time type safety for stored values
- Improves IntelliSense and prevents type mismatches
- Updates mappers, store, tests, and helper functions consistently
- No runtime changes, pure TypeScript improvement

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [refactor] address @arjansingh code quality feedback

- Remove AI-generated refactoring comment that adds no value
- Reorganize tests with nested describe blocks for better readability
- Group related test cases by function for easier scanning

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [refactor] move makeLinkSegmentKey to layoutUtils - addresses @arjansingh's file organization feedback

- Move string concatenation function from layoutMath.ts to new layoutUtils.ts
- Keep layoutMath.ts focused on pure geometric calculations
- Create dedicated layoutUtils.ts for general layout utilities
- Update imports in store and create separate test file
- Improves module cohesion and clarity of purpose

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [cleanup] remove leftover AI refactoring comments

- Remove "Constants moved to utils" and "Node layout mapping moved to utils"
- Clean up extra blank lines from previous refactoring
- Keep meaningful organizational comments like "Helper methods"

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [cleanup] remove unnecessary import aliases

Remove pointInBoundsUtil/boundsIntersectUtil aliases as there are no
naming conflicts. Use direct function names for cleaner code.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [refactor] improve Y.Map typing with named NodeLayoutMap type - addresses @DrJKL's performance and type safety suggestions

- Create named NodeLayoutMap type for TypeScript performance optimization
- Improve getOr function with proper key constraints and type safety
- Update all Y.Map<NodeLayout[keyof NodeLayout]> usages to use NodeLayoutMap
- Remove manual type assertions in favor of generic key constraints
- Clean up unused imports and fix formatting issues

* [cleanup] remove explanatory comment per @DrJKL's preference

* don't wait for dialog close button to be stable

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-13 21:17:09 -07:00
..
2025-08-27 06:10:15 -07:00

ComfyUI Frontend Testing Guide

This guide provides an overview of testing approaches used in the ComfyUI Frontend codebase. These guides are meant to document any particularities or nuances of writing tests in this codebase, rather than being a comprehensive guide to testing in general. By reading these guides first, you may save yourself some time when encountering issues.

Testing Documentation

Documentation for unit tests is organized into three guides:

Testing Structure

The ComfyUI Frontend project uses a mixed approach to unit test organization:

  • Component Tests: Located directly alongside their components with a .spec.ts extension
  • Unit Tests: Located in the tests-ui/tests/ directory
  • Store Tests: Located in the tests-ui/tests/store/ directory
  • Browser Tests: These are located in the browser_tests/ directory. There is a dedicated README in the browser_tests/ directory, so it will not be covered here.

Test Frameworks and Libraries

Our tests use the following frameworks and libraries:

Getting Started

To run the tests locally:

# Run unit tests
pnpm test:unit

# Run unit tests in watch mode
pnpm test:unit:dev

# Run component tests with browser-native environment
pnpm test:component

Refer to the specific guides for more detailed information on each testing type.