Closed joeythomaschaske closed 1 year ago
Ok I think I figured it out, in my jest.config.js
I wasn't setting transformIgnorePatterns
to ignore everything but my npm package with my mocks.
However, there's not a good way to add my npm packages to this with out also including what sfdx-lwc-jest
has in its base jest config
transformIgnorePatterns: [
'/node_modules/(?!(.*@salesforce/sfdx-lwc-jest/src/lightning-stubs)/)',
],
So I have to manually include this, which means if the source config changes it could cause problems
transformIgnorePatterns: [
'/node_modules/(?!(.*@salesforce/sfdx-lwc-jest/src/lightning-stubs|@komodohealth)/)'
],
Additionally, someone on my team notified me about "Plug n Play" modules which is an entirely different format for storing external dependencies. They warned reaching into node_modules
probably won't work with pnp modules.
sfdx-lwc-jest
reaches into node_modules today, will this break using plug n play?
This sounds like a question, so I think this issue can be closed. Please reopen if I'm mistaken.
I haven't tested plug n play personally, but in general, I would expect it to not be compatible with everything in the Node.js ecosystem, and there may be something in sfdx-lwc-jest
that is incompatible, yes.
Description
I am a package developer and have multiple 2gp packages contained in their own separate repos. These packages form dependencies.
If a package contains LWCs I would like to publish mocks via npm so that other managed packages that depend on it can use them if they use the components from the package.
I am running into errors attempting to configure jest to use the mocks that are located in
node_modules
when the package is installedAdditionally, I have requested an example of how to do this correctly in the LWC Recipes repo
Steps to Reproduce
__mocks__
jest.config.js
viamoduleNameMapper
to use the mock fromnode_modules
Example
jest.config.js
:Expected Results
Jest uses the mock from
node_modules
Actual Results
Version
Additional context/Screenshots
node_modules
content:node_modules/@komodohealth/p-pltfm-core/__mocks__/uiMessage.js
contents: