menu

Testing Library

Simple and complete DOM testing utilities that encourage good testing practices.

Channels
Chat
view-forward
# All channels
view-forward
# General
view-forward
# General Help
view-forward
# Angular Help
view-forward
# Cypress Help
view-forward
# DOM Help
view-forward
# React Help
view-forward
# TestCafe Help
view-forward
# Vue Help
view-forward
Team

Using await wait properly

February 21, 2020 at 7:42pm

Using await wait properly

February 21, 2020 at 7:42pm
Is this correct syntax?
await wait(() => expect(something).toBeVisible());
Because I get the same results whether I use .not.toBeVisible()

February 26, 2020 at 3:58pm
I think it is indeed incorrect and should be something like:
const something = getByText(/some text/i);
await wait(() => something);
expect(something).toBeVisible()
Edited
  • reply
  • like
Ah ok so :
await wait(() => {
expect(something.toBeInTheDocument()
})
// wait for appearance and return the element
const theThing = await waitForElement(() => something)
  • reply
  • like