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

.not not exposed #45

Closed
maxime-helen opened this issue Jan 15, 2021 · 2 comments
Closed

.not not exposed #45

maxime-helen opened this issue Jan 15, 2021 · 2 comments
Labels
question Further information is requested

Comments

@maxime-helen
Copy link

playwright-core: ^1.7.1
playwright-expect: 0.3.0

I am trying following code per documentation

await expect(page).not.toHaveSelector("#foobar", {
  timeout: 1 * 1000
})

However I get following error:

    TypeError: Cannot read property 'toHaveSelector' of undefined

      11 | 
      12 | export const isWidgetMessageHidden = (page) => {
    > 13 |   return expect(page)
         |          ^
      14 |     .not
      15 |     .toHaveSelector(selectId(REFERRAL.WIDGET_MESSAGE))
      16 | }

Logging shows below:

console.log(expect(page));

/* returns below, missing not method
    {
      toHaveText: [AsyncFunction: toHaveText],
      toEqualText: [AsyncFunction: toEqualText],
      toHaveSelector: [AsyncFunction: toHaveSelector],
      toEqualValue: [AsyncFunction: toEqualValue]
    }
*/

Am I missing something? Many thanks for these great helpers!

@mmarkelov
Copy link
Member

@maxime-helen seems like that you are using expect-playwright without jest, so this is expected behaviour.

@mmarkelov mmarkelov added the question Further information is requested label Jan 16, 2021
@maxime-helen
Copy link
Author

I was importing expect straight from test script, called with jest CLI. Configuring my jest.config.js instead with setupFilesAfterEnv: ['expect-playwright'] fixed the problem! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants