无法使用TypeScrip在Cypress的每个循环内返回值.patientBalance
值未定义.
主类代码
let patientBalance: number = getPatientBalance(claimNumber);
功能如下:
let amountInDollar1: string[];
let amount1: number;
export let getPatientBalance = (claimNumber: string) => {
getClaimNumberCells().each((input, index) => {
const claimText = input.text();
getChargesTable().scrollTo('right');
if (claimText.includes(claimNumber)) {
getPatientBalanceCell()
.eq(index)
.each((data) => {
amountInDollar1 = data.text().split('$');
amount1 = parseFloat(amountInDollar[1]);
console.log('Amount in loop', +amount1);
});
}
});
return amount1;
};
此外,我想在整个测试过程中在多个点上使用这patientBalance
个.如何将此值赋给变量?