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

Getting error when trying to pass in a matcher function #66

Open
clicktime-michael opened this issue Jan 18, 2022 · 2 comments
Open

Getting error when trying to pass in a matcher function #66

clicktime-michael opened this issue Jan 18, 2022 · 2 comments

Comments

@clicktime-michael
Copy link

clicktime-michael commented Jan 18, 2022

When calling the following code on windows and Mac, using different node versions, including v16:

import puppeteer from 'puppeteer';
import 'pptr-testing-library/extend';

it('should be titled correctly', async () => {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto('https://Google.com');
    
    const $document = await page.getDocument();
    const $email = await $document.getAllByText(() => true);
    
    expect(true).toBeTruthy();
  });

We get the following Error:

Evaluation failed: Error: It looks like undefined was passed instead of a matcher. Did you do something like getByText(undefined)?

      at assertNotNullOrUndefined2 (__puppeteer_evaluation_script__:2632:17)
      at matches2 (__puppeteer_evaluation_script__:2653:9)
      at __puppeteer_evaluation_script__:15045:152
          at Array.filter (<anonymous>)
      at queryAllByText3 (__puppeteer_evaluation_script__:15045:135)
      at __puppeteer_evaluation_script__:14733:23
      at Object.getAllByText (__puppeteer_evaluation_script__:14765:21)
      at anonymous (__puppeteer_evaluation_script__:19475:31)
      at ExecutionContext._evaluateInternal (node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)

We had a more complex matcher, but even just passing in () => true throws the same error.

@Izhaki
Copy link

Izhaki commented May 19, 2022

Same here. Trying to follow Kent Dodds suggestion regarding nested text matching.

@patrickhulce
Copy link
Collaborator

Yeah this is going to be rough, we can't serialize functions over the puppeteer boundary easily and even if we end up doing this you won't get access to the closure like you would normally expect :/

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

No branches or pull requests

3 participants