-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Handlebars: Access has been denied to resolve the property in console logs during unit tests in React #1637
Comments
The warning is printed because the code coverage report is actually not working correctly. Istanbul-reports have been broken with the 4.6.0 release of handlebars and the warning is printed to point to the correct handlebars configuration to change on such cases. See #1636 for details and #1633 for more details about the reason for the breaking change in a minor version bump. You can also open the link in the warning to see how to make it go away, but if you are using handlebars as third or fourth level dependency, I guess you can't. Sorry about the hassle, but I still believe it was the right thing to do. |
That link also contains links to all the security advisories that ultimately led to the changes we made. |
I also have this issue as well and opening the link does nothing as there is no webserver running. While I do understand, after looking into the other issues, why the change was needed, introducing this as a breaking minor change is against SEMVER Spec #8. It's going to be especially challenging for those, like my team, that use handlebars as a 5th level dependency When jestjs/jest#9355 is resolved/released and the move to using instanbul 3.0.0 is complete this issue should not be a problem as there is no dependency on handlebars. Is there any guidance on how to fix this in the interim? |
I could try to change so that the log output is only printed once. Is this breaking your build or just log annoyingly much data? |
I think you could also disable the HTML coverage reporter until this is resolved. |
Istanbul is also working on a backport of the new HTML reporter to 2.x |
An new version of "istanbul-reports" is published, mentioned in #1636 |
@antempus the logged message should be something like... Argh, I just noticed I copied the link-url while running the local dev-server of the Handlebars homepage. I'll fix it in the next release. |
Super annoying as in most cases it prints 1000+ times ... If you could just say access denied x times and if array is greater than x only print once.... That would make this much more tolerable |
I have just pushed a change that will log it only once per property. And fix the link url. |
and it's released 4.7.1 |
Hello, I'm using handlebars 4.7.1 with webpack, i.e through handlebars-loader. After reading the handlebars API ref, I've changed my webpack loader config: {
test: /\.hbs$/,
loader: 'handlebars-loader',
query: {
precompileOptions {
allowProtoPropertiesByDefault: true,
allowProtoMethodsByDefault: true
},
helperDirs: [path.join(__dirname, 'src/view/helpers')]
}
}, But I still get the errors:
Any clue to fix that? |
Check the docs for the handlebars-loader on how to pass runtime options. It is not a compile option but runtime. |
You need to pass the options as second parameter to the template function that is the result of your import. |
Thank you for your quick answer (sorry for being a bit off subject). I didn't know it is possible to pass options as 2nd param. I tried, it works, but, if possible, I'd like to declare it once for all in my wekpack config. For those who would be interested, I opened an issue on the handlebars-loader repo. |
So what you're saying is that I can't do something like this => |
Not if "parent.hasOwnProperty('budget')" returns false. You can disable that check in a runtime option, but I would suggest creating the input objects such that all relevant properties are own properties. The problem occur when you are using custom classes as input and my preferred solution would be that you add a method that returns an actual plain javascript object. If the people writing your templates are the same as people writing the code, you can also disable the safety checks. The error message contains a link to the documentation that tells you how to so that. |
hi @nknapp thank you for the info. I'm wondering (as a noob-ish handlebars user) what I can do to "[create] the input objects such that all relevant properties are own properties"? |
i stringgified my obeject with JSON.stringify and I parsed it back with JSON.parse. |
Everytime I run my unit tests since upgrading to Babel 7, I see a long list of console logs with this message in them...
How do I make this go away?
What is most disturbing is you disabled a lint rule in your release to make it happen...
*Note: It only happens when running coverage on untested files...
The text was updated successfully, but these errors were encountered: