0

How to test a functional component that is using a fragment and props, but is not using markup, I cannot set a role.

const Item = (props: ItemProps) => (
    <React.Fragment>
        { props.content }
    </React.Fragment>
);
Tabares
  • 4,083
  • 5
  • 40
  • 47

1 Answers1

1

I don't see what assurance would a test give you on this particular component.

Assert whatever is in props.content. If you're using react-testing-library (as you tagged the question with that), just use the corresponding query, this article from the official docs should help deciding which query is appropriate, based on your logic (that you haven't shared in your question).

You always want to test the behaviour, rather than the implementation, this is especially true with the front-end and with react-testing-library, like the creator of the library pointed out as well. So don't be too hang up on this particular component, look inside see what you can test there.

anddak
  • 611
  • 1
  • 6
  • 17