Closed
Description
getByText - the below script with getByText() works fine
async checkActiveStatusdom(text) {
const header = await this.screen.findByTestId('erow-GroupCode-0');
console.log(" header" + header)
const base = this.within(header).getByText("NEW HIRE")
console.log("base value" + base);
const check = this.within(header).getByText("check")
console.log(" value " + check)
await expect(base).toContainText(text);
}
however findByText - returns Error: toContainText can be only used with Locator object
async checkActiveStatusdom(text) {
const header = await this.screen.findByTestId('erow-GroupCode-0');
console.log(" header" + header)
const base = this.within(header).findByText("LINEHOLDER")
console.log("base value" + base);
const check = this.within(header).findByText("check")
console.log(" value " + check)
await expect(base).toContainText(text);
console log:
headerLocator@query-by-test-id=["erow-GroupCode-0"]
base value[object Promise]
value [object Promise]
why getByText auto waits, but findByText returns no value, and returns Error: toContainText can be only used with Locator object.
From the previous ticket , #507
I was told that findby auto waits and getby does not auto wait, in this scenario it works differently.