fluxxor icon indicating copy to clipboard operation
fluxxor copied to clipboard

Jest throws TypeError ending in lodash-node/lang/isNative

Open BinaryMuse opened this issue 9 years ago • 1 comments

See the comments at 8eea48c6a65febee91093e3fb4af454261246852

@svnlto we have a simple component test using jestand that break using 1.5.2:

TypeError: 
/home/jenkins/workspace/redacted/src/app/components/contacts/__tests__/header-test.js: 
/home/jenkins/workspace/redacted/src/app/components/contacts/header.js: 
/home/jenkins/workspace/redacted/src/app/components/starred/index.js: 
/home/jenkins/workspace/redacted/node_modules/fluxxor/index.js: 
/home/jenkins/workspace/redacted/node_modules/fluxxor/lib/dispatcher.js: 
/home/jenkins/workspace/redacted/node_modules/fluxxor/node_modules/lodash-node/modern/lang/clone.js: 
/home/jenkins/workspace/redacted/node_modules/fluxxor/node_modules/lodash-node/modern/internal/baseClone.js:
/home/jenkins/workspace/redacted/node_modules/fluxxor/node_modules/lodash-node/modern/internal/baseForOwn.js:
/home/jenkins/workspace/redacted/node_modules/fluxxor/node_modules/lodash-node/modern/object/keys.js:
/home/jenkins/workspace/redacted/node_modules/fluxxor/node_modules/lodash-node/modern/lang/isNative.js: Cannot call method 'replace' of undefined

followed by

@xMartin Hey, it seems to happen if a dependency of a component requires Fluxxor.

Check this demo project: https://github.com/xMartin/fluxxor-issue

and

@BinaryMuse Wow, that's really quite unfortunate. Thanks for the repro case, it helped a ton.

It looks like it's choking on object/keys down in lang/isNative, which is used by a bunch of the other functions (not just object/clone). I'm not sure why. Adding <rootDir>/node_modules/fluxxor to unmockedModulePathPatterns fixes the issue in the demo project, as does adding jest.dontMock("fluxxor") to the test. Not sure if that will affect your other tests or not, but might be a starting point.

I'm not really familiar with the Jest internals and don't really understand why this is an issue, but I'll continue to look into it. Let me know if the workaround above works for you, and I'll continue to look into a more permanent fix.

BinaryMuse avatar Feb 03 '15 16:02 BinaryMuse

I had to add "fluxxor" and "lodash-node" to my unmockedModulePathPatterns to get past this error.

techapman avatar May 18 '15 21:05 techapman