Problem when using WebPartTitle component
Leif-Frederiksen opened this issue · comments
I get a problem when I have a component that uses the WebPartTitle component (part of the @pnp/spfx-controls-react project).
In that case I get this error when running the test:
● Test suite failed to run
Cannot find module 'ControlStrings' from 'WebPartTitle.js'
at Resolver.resolveModule (../node_modules/jest-resolve/build/index.js:169:17)
at Object.<anonymous> (../node_modules/@pnp/spfx-controls-react/lib/controls/webPartTitle/WebPartTitle.js:14:15)
Any ideas on how to resolve this problem?
Thanks... I'll make sure I include this in the future fix. For the short term, you can use a similar workaround mentioned in #1. But the preset should be able to avoid these issues.
Update - I understand why this is happening, but I can't figure out how to fix it for a bigger set of circumstances.
It's easy to fix for just the one library you're using, but this will quickly turn into a +1 issue when someone uses another library, so I'm looking for a more dynamic solution... this is affecting all three of my presets...
Still working...
Haven't forgotten about this, but in the short term, you could look to just mock that object up like I mention here: #1 (comment)
I'm going to close this issue... I'm not entirely sure how to handle this. The challenge is that SPFx is loading that module on demand on the page (see the config.json
folder)... so you somehow have to tell Jest where to find that module. Not sure how this would be done... sorry :(