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

TypeError: Function.prototype.name sham getter called on non-function #114

Open
Ridermansb opened this issue Oct 3, 2018 · 5 comments
Open
Labels

Comments

@Ridermansb
Copy link

When run with --coverage i get this error..

TypeError: Function.prototype.name sham getter called on non-function

● <ErrorBoundary> component › should render with message if error occour

TypeError: Function.prototype.name sham getter called on non-function

  20 | 		);
  21 |
> 22 | 		expect(wrapper).toMatchSnapshot();
     | 		                ^
  23 | 	});
  24 |
  25 | 	it("should render if error occour", function() {

  at Function.getName (../node_modules/function.prototype.name/implementation.js:31:9)
  at displayNameOfNode (../node_modules/enzyme-adapter-utils/build/Utils.js:156:95)
  at ReactSixteenAdapter.displayNameOfNode (../node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:605:62)
  at typeName (../node_modules/enzyme/build/Debug.js:60:43)
  at internalNodeToJson (../node_modules/enzyme-to-json/mount.js:70:31)
  at mountToJson (../node_modules/enzyme-to-json/mount.js:93:12)
  at Object.<anonymous>.exports.default (../node_modules/enzyme-to-json/index.js:14:32)
  at Object.print (../node_modules/enzyme-to-json/createSerializer.js:22:40)
  at printPlugin (../node_modules/pretty-format/build/index.js:287:16)
  at prettyFormat (../node_modules/pretty-format/build/index.js:485:16)
  at Object.throwingMatcher (../node_modules/expect/build/index.js:320:33)
  at Object.toMatchSnapshot (src/components/molecules/ErrorBoundary/ErrorBoundary.test.jsx:22:19)

`

If I not run with coverage, everything works fine

Question posted on Stackoverflow

@MaxwellBo
Copy link

@Ridermansb might want to mention that you also reported this bug to enzyme proper enzymejs/enzyme#1889

@jamesbarry93
Copy link

Not sure if this got resolved - as I can't see the rest of your test it's hard to tell if you have the same issue as me.

I managed to resolve the issue by changing my .find('a#someid') to actually reference the type - so .findWhere(field => field.type() === FieldText && field.prop('id') === 'displayName')

This may help someone with a similar issue!

@AaronV
Copy link

AaronV commented Dec 8, 2021

I'm running into a related problem. I'm not getting the "sham getter" issue, but I am getting different snapshot results when I use --coverage vs. not use it. I just upgrades to styled-components 5 and that started the problem.

@ljharb
Copy link

ljharb commented Dec 8, 2021

That seems like an issue with whatever --coverage is, since coverage tools often need to transform code in order to record coverage - it seems entirely unrelated to this issue.

@AaronV
Copy link

AaronV commented Dec 8, 2021

That seems like an issue with whatever --coverage is, since coverage tools often need to transform code in order to record coverage - it seems entirely unrelated to this issue.

Thank you @ljharb, that comment helped! It seems that displayName stability was never guaranteed (for snapshots) and we've been lucky thus far. styled-components/babel-plugin-styled-components#151

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

No branches or pull requests

6 participants