0
<tbody data-testid="offers-list-tablebody">
            { offers.map((Offer) => (
              <tr onClick={this.handleTermsAndConditionsBtnClick} style={{ cursor: "pointer" }} key={index}>
}

I tried in this way

 const tableBody = list.find("[data-testid='offers-list-tablebody']");

    const tableRow1 = tableBody.childAt(0);

    const clickElement1 = (tableRow1.key());
    expect(clickElement1.onclick).toBeTruthy();
    expect(clickElement1).toHaveStyle("cursor: pointer");

The error is Property "onclick does not exist on type string" and it is hsowing value of index when tested. How to test this?

akhil
  • 31
  • 5

1 Answers1

1

it is because you are assigning clickElement1 to tableRow1.key() which returns a string.

Replace clickElement with tableRow1 like below

    expect(tableRow1.onclick).toBeTruthy();
Samantha
  • 751
  • 2
  • 6
  • 18