-
-
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
Function.prototype.name sham getter called on non-function #2439
Comments
@vasush please downgrade until everything works again, and then upgrade enzyme to v3 latest (not 3.3, 3 latest) first, before trying to upgrade react. Then, we can figure out if the issue is due to the enzyme upgrade or the react upgrade :-) |
I have the same issue with functional components. |
Closing for now; happy to reopen if you narrow down if it's the enzyme upgrade, or the react upgrade, that breaks your tests. |
@ljharb what about this point ? I can confirm this behaviour. In my case I use the following code:
It does not work and throws the 'Function.prototype.name sham getter called on non-function' error. If I use only class name as a selector it works as expected:
The 'find' method is not related to React API. Is not it? |
@SergeyAlexeev |
@vasush are you running these tests in the browser, or in node? i assume the browser since you're using webpack. @SergeyAlexeev we have a test for tagname + className: https://github.com/enzymejs/enzyme/blob/master/packages/enzyme-test-suite/test/shared/methods/find.jsx#L86-L94. Where are you running your tests? For both of you, which webpack version are you using? |
Unfortunately my project is placed in a private repo and I can't share it. I'll try to create a minimal sample that demonstrates the issue soon.
I'm running my tests in node using the following packages: "webpack": "4.44.1", |
Even knowing the contents of just TableComponent would be helpful, but if that's not an option I'll wait for a repro repo. If you're running your tests in node, why do you need webpack? or are you having these issues in karma (which runs tests in a browser, not in node) |
Hi @ljharb , I've created a repo that reproduces the issue. There is the Table component that contains inner HeaderCellContent functional components. Look at the table-test.js file. Currently it works fine. But if you uncomment this line the test will fail with error - 'Function.prototype.name sham getter called on non-function'. Hope it helps to improve enzyme! :) |
One more thing. My env:
|
Thanks, that is perfect. The issue is that the |
…-like Caused by #54; see enzymejs/enzyme#2439
v1.2.1 of I was unable to get repeatable phantomjs tests set up; see inspect-js/is-callable#56 for that. Fixed in inspect-js/is-callable@579179e. |
I am facing the same issue, but I am not using is-callable in my package.json. But I see it in my package-lock.json as part of other dependencies like es-abstract, enzyme etc. Please help. |
Could you please tell what are the steps if we have lock file. |
The simplest is to remove the lockfile and rerun |
Even after installing in-callable 1.2.1, I get the same error. |
Are you sure npm ls only includes one copy of is-callable? Have you reran any relevant build process? |
Yes, I checked t that. |
If you can reproduce the error, a new issue with a repro repo would be most helpful. |
Hi @ljharb , Sorry for delay, I was a little busy)) I've updated is-callable to v1.2.1 but the error still appears:
As far as I understand, this line from 'is-callable' works wrong. One more point.
I'm absolutely sure, that my functional component has props. At the same time, if I update my component like below:
The error will go away. It looks very strange, because in my code HeaderCellComponent always has props and works as expected. But is-callable tries to run functional component with the 'badArrayLike' arg and it does not work. I'm not sure, I should provide an empty object as default props for each functional component in my project. |
@SergeyAlexeev you're 100% right that you should not have to do that, and the bug in is-callable was specifically that it didn't ensure that the exception thrown was the The line you highlighted is wrong, which is why inspect-js/is-callable@579179e was needed to fix it. However, strangely enough, I don't see the actual fix in that commit - so I think I need to include it and publish a v1.2.2 (-‸ლ) I'll do that shortly! |
Caused by #54; see enzymejs/enzyme#2439
Reopened; v1.2.1 doesn't actually contain the fix. Will close when v1.2.2 is published, after npm becomes available again. |
is-callable v1.2.2 is released. Please let me know if updating to that doesn't fix this issue. |
@ljharb thanks a lot! Now it works like a charm!)) |
Hi i am new to enzyme and i got this error while testing a functional component.
error :=>
Codebase :=>
Environment :=>
API
enzyme | 3.3.0
react | 16.4.1
react-dom | 16.4.1
react-test-renderer | 16.4.1
adapter | enzyme-adapter-react-16 (^1.15.2)
chai | 3.5.0
This functional component test cases faliure occurred once i upgraded my react version from 15.6.1 to 16.4.1 and enzyme version from 2.9.1 to 3.3.0
The text was updated successfully, but these errors were encountered: