-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
Promise rejected with: 'cov_2itgu9hdrb is not defined #514
Comments
@farhan2106 could you share a minimal reproduction of this bug with nightmare.js? I think you've probably found a legitimate edge-case with the instrumenter, which is returning a line counting variable rather than a promise. |
@bcoe I have created a sample project to replicate the error. Again, if we comment out the The sample code is from Nightmare js github itself. |
@farhan2106 I have some capacity this weekend, I will try to get back to you on this soon! Thanks for your patience. |
@JaKXz Thanks for the help :) |
@farhan2106 so I'm able to reproduce the issue, which is good. I tried disabling |
@JaKXz I have same issue with @farhan2106, Is issue fixed? thank you. |
Thanks for the ping @duytran, I'm unfortunately not available to look deeper. FWIW my fork is still alive: https://github.com/JaKXz/temporary-nyc-error/tree/fix/cov-error and you should be able to reproduce the error there. If you're able, feel free to dig into the issue and for many bonus points try to add a failing test :) though that is a lot of bonus points, because the issue might be in the |
@JaKXz thank for reply :)! I will try look around. Thank you. |
@duytran @farhan2106 doing some issue cleanup; sorry that I haven't gotten to this bug yet -- will try to get a test around it as soon as possible. |
Thank @bcoe! |
Nightmarejs converts functions passed to The solution is to use Istanbul's coverage comment syntax: browser
.goto('http://...')
.evaluate(
/* istanbul ignore next */
() => document.getElement('my-div').innerText
)
... |
add /* istanbul ignore next */ before page.evaluate accordingu to istanbuljs/nyc#514 (comment)
@keithkml great find. Thank you for your explanation. It would definitely be worth documenting this in a gotchas section or something. Making this comment to myself to get on it, or, for anyone who wants an easy contribution :) |
Without the fix I was getting
The line const evaluateRes = await page.evaluate(
/* istanbul ignore next */
(selector) => {return selector}, this.selector
) I am trying to make a base scraper class, where the inherited scraper classes have different evaluate method. class ScraperBase{
evaluate(selector) {
return selector
}
run() {
const browser = await puppeteer.launch()
const page = await browser.newPage();
// ...
const evaluateRes = await page.evaluate(
/* istanbul ignore next */
this.evaluate, this.selector
)
}
} Now I am getting
again |
@epyx25 in the example you posted you need: class ScraperBase{
/* istanbul ignore next */
evaluate(selector) {
return selector
}
// ...
} It's important that you prevent instrumentation of the body of the function that will be sent to the browser, so the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I got the following bugs.
Promise rejected with: 'cov_2itgu9hdrb is not defined'
I am using Nightmare.js for browser automation. After investigation, the above error is thrown when I use
Nightmare.evaluate
api. When I remove any references toNightmare.evaluate
it is able to do coverage properly.Am not sure it is an error with nyc or nightmare.
Forensic Information
v6.9.1 3.10.8 /Users/farhanghazali └── (empty)
The text was updated successfully, but these errors were encountered: