0

Recently, I got some error when running the E2E tests and the only change I made is adding the checkColumns logic in the original test code as following:

it('check search and sort', async () => {
  await checkLoadingAndResult();
  await checkColumns(table, ...columns); //newly added 
  await checkTableSorting();
});

The logic of checkColumns is like:

export async function checkColumns(table: Table, ...columns: string[]) {
  for (const col of columns) {
    expect(await table.isColumnDisplayed(col)).toBeTruthy(`${col} is not displayed`)
  }
}

The error message is like:

Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:59536

I think maybe there's something wrong in the checkColumns function and I don't know whether it's a correct way to call async methods inside a for-loop. And I guess this for-loop is the cause of the error.

  • Assuming `table.isColumnDisplayed` returns a promise (is an `async` function), then yes, the way you're calling it is just fine. – T.J. Crowder Apr 02 '20 at 13:18
  • Thanks T.J.Crowder! table.isColumnDisplayed() returns a promise. I have struggled with the ECONNREFUSED error for a whole day. Maybe I need to find other causes of this error. – CrazyDonuts Apr 02 '20 at 13:23
  • Please show the code of function isColumnDisplayed(). And clarify your code can always pass without `await checkColumns(table, ...columns); ` even now. As `djiss` said, your error not seems to related to the `checkColumns()` according to my experience. – yong Apr 03 '20 at 14:32

1 Answers1

1

This error message is not generated by your usage of async / await. It is most likely displayed because the HTTP request sent failed due to a connection error, I had the issue on another framework and it was due to the webdriver that was not running.

jcoleau
  • 1,112
  • 7
  • 20