Skip to content

Shallow Rendering based on Component Factories #396

@egil

Description

@egil

The goal is to make shallow rendering possible, with as few caveats as possible.

It should:

  • Mimic shallow rendering principles from other component testing frameworks, e.g. React
  • Replace all child components of the component under test with stub components
  • Not replace components added to TestContext.RenderTree
  • Stub components should be represented in the DOM tree as the component they have replaced, with correct casing.
  • Shallow rendering does not replace CascadingValue<T> which are part of the render fragment being rendered.
  • Enable stub/shallow options to be passed to shallow render methods to control how removed components are replaced.

Limitations:

  • ShallowRender will only render the first top level component. Other components, including its children will be stubbed.
  • Once a test context has been used to perform a shallow render, its Render, ShallowRender, and RenderComponent methods will all throw an exception, with the message The test context has previously been used to perform a shallow render of a component or render fragment. Rendering another component or render fragment with the same test context is not currently supported, since it can result in unpredictable results.. This limitation might be removed in the future, but right now I do not see a neat way to achieve this.

Replaces #17.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions