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

ReferenceError: cov_1hphpf4qcw is not defined #5175

Closed
frantallukas10 opened this issue Nov 16, 2019 · 10 comments
Closed

ReferenceError: cov_1hphpf4qcw is not defined #5175

frantallukas10 opened this issue Nov 16, 2019 · 10 comments

Comments

@frantallukas10
Copy link

I have problem create test for my function
image
here is my project https://github.com/frantallukas10/youtu-get
I try to create test for my function where I use puppeteer for get every title and id from youtube playlist
here is my test: https://github.com/frantallukas10/youtu-get/blob/master/tests/test.js
and here is my function: https://github.com/frantallukas10/youtu-get/blob/master/src/main.js

thank you for your help or information... =)

@kblok
Copy link
Contributor

kblok commented Nov 17, 2019

Can you point us to the evaluate call that is failing?

@frantallukas10
Copy link
Author

Can you point us to the evaluate call that is failing?

when I run my function everything work properly. My result is correct. but If I try to test my function I have the issue

@kblok
Copy link
Contributor

kblok commented Nov 18, 2019

Your code coverage tool is injecting code

console.log node_modules/puppeteer/lib/ExecutionContext.js:108
    () => {
          /* istanbul ignore next */
          cov_npcpcae6x.f[2]++;
          cov_npcpcae6x.s[19]++;
          window.scrollTo(0, document.getElementsByTagName('ytd-app')[0].getBoundingClientRect().height);
        }
    //# sourceURL=__puppeteer_evaluation_script__

That code is being sent and executed in Chromium. On the browser side, cov_npcpcae6x doesn't exist.

@frantallukas10
Copy link
Author

thank you for your help!
how can I fix it? can I use another function from puppeteer? I need scroll down if all songs are not visible in YouTube playlist I can use another function for scroll down but I don't think that it will fix it

@kblok
Copy link
Contributor

kblok commented Nov 19, 2019

@frantallukas10 They talk about that here jestjs/jest#7962 and here jestjs/jest#6793

As a workaround, you can also send the function as a string, so no one gets in the middle.

@frantallukas10
Copy link
Author

testPathIgnorePatterns helped me with my issue https://jestjs.io/docs/en/configuration#testpathignorepatterns-arraystring
I exported every puppeteer evaluate methods from file and added to testPathIgnorePatterns config

@frantallukas10
Copy link
Author

maybe it will be better add this information for this error... @kblok

@pgoos
Copy link

pgoos commented May 23, 2021

@kblok could you elaborate on sending the function as a string, maybe with an example?
Right now the only workaround that I see is @frantallukas10 approach to add every file that uses evaluate methods into jest config property testPathIgnorePatterns

@kblok
Copy link
Contributor

kblok commented May 24, 2021

@pgoos the jest team added an explanation in their docs :) https://jestjs.io/docs/puppeteer

@Barzou
Copy link

Barzou commented Oct 20, 2022

Thanks for the response @kblok
I solved my problem adding /* istanbul ignore next */ before page.evaluate calls :

/* istanbul ignore next */
const { headerHTML, footerHTML } = await page.evaluate(() => {
  ....
}

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

4 participants