Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property 'exists' does not exist on type 'NodeSnapshot'. #332

Open
AdrienLemaire opened this issue Feb 24, 2022 · 1 comment
Open

Property 'exists' does not exist on type 'NodeSnapshot'. #332

AdrienLemaire opened this issue Feb 24, 2022 · 1 comment
Labels
help wanted Extra attention is needed STATE: Need response

Comments

@AdrienLemaire
Copy link

Describe the bug
Following the documentation, I tried to write the following test

const main = Selector('main[role="main"]');
const dialog = Selector('div[role="dialog"]');

signin = within(main).queryByText("Sign in");
google = within(dialog).queryByText(/Google/i);

test("user clicks the sign-in button", async (t) => {
  await t
    .expect(google.exists)
    .notOk("Modal should not be opened")
    .takeScreenshot()
    .click(signin)
    .expect(google.exists)
    .ok("Modal is opened")
    .takeScreenshot();
}

When running tests, I get the following error pointing on the notOk line

   1) An error occurred in Selector code:

      TypeError: Expected container to be an Element, a Document or a DocumentFragment but
      got undefined.

And when trying to console.log the value of await googe.exists, I get

ERROR Cannot prepare tests due to the following error:

Error: TypeScript compilation failed.
/path/to/e2e/signin.ts (7, 27): Property 'exists' does not exist on type 'NodeSnapshot'.

Expected behavior

I thought from reading the examples that @testing-library/testcafe queries would return a TestCafe Selector object, making properties like exists available.

Here's a working test without using testing-library

  const main = Selector('main[role="main"]');
  const dialog = Selector('div[role="dialog"]');

  const signin = main.find("button").withText("Sign in");
  const google = dialog.find("button").withText("Google");

  await t
    .expect(google.exists)
    .notOk("Modal should not be opened")
    .takeScreenshot()
    .click(signin)
    .expect(google.exists)
    .ok("Modal is opened")
    .takeScreenshot();
@benmonro
Copy link
Member

benmonro commented Jun 9, 2022

would welcome a PR if you want to take a stab at fixing this. :)

@benmonro benmonro added the help wanted Extra attention is needed label Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed STATE: Need response
Projects
None yet
Development

No branches or pull requests

2 participants