Skip to content

Support assertion of JSX conditional rendering #2

@viktor-podzigun

Description

@viktor-podzigun

The following assertion should be supported:

assertComponents(
  result.children,
  <div>
    {showHeader ? <h1>Welcome!</h1> : null}
    <p>Hello</p>
  </div>
);

Current behaviour: if showHeader is false assertion is failing in this false-positive case:

AssertionError: Children count doesn't match for div
	actual:   1
	expected: 2

Expected behaviour: assertion should pass in this case

Current workaround is filtering out null components on calling side:

assertComponents(
  result.children,
  showHeader ? (
    <div>
      <h1>Welcome!</h1>
      <p>Hello</p>
    </div>
  ) : (
    <div>
      <p>Hello</p>
    </div>
  )
);

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