fluxxor
fluxxor copied to clipboard
Jest throws TypeError ending in lodash-node/lang/isNative
See the comments at 8eea48c6a65febee91093e3fb4af454261246852
@svnlto we have a simple component test using
jest
and that break using1.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 inlang/isNative
, which is used by a bunch of the other functions (not justobject/clone
). I'm not sure why. Adding<rootDir>/node_modules/fluxxor
tounmockedModulePathPatterns
fixes the issue in the demo project, as does addingjest.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.
I had to add "fluxxor" and "lodash-node" to my unmockedModulePathPatterns
to get past this error.