Can moduleNameMapper [object<string, string>] support moduleNameMapper [object<string, function>]?
See original GitHub issue🚀 Feature Proposal
Can moduleNameMapper [object<string, string>] support moduleNameMapper [object<string, function>]
Motivation
Because our project is multi-country, we need to import different component according to environment variable.
Example
It can be configured like this:
'^@src(.*)$': function (path){ },
Pitch
Why does this feature belong in the Jest core platform?
Common feature proposals that do not typically make it to core:
- New matchers (see jest-extended)
- Changes to the default reporter (use custom reporters instead)
- Changes to node/jsdom test environments (use custom environments instead)
Issue Analytics
- State:
- Created 5 years ago
- Comments:13
Top Results From Across the Web
Jest moduleNameMapper to find files: "resolver": undefined
I now have another module not being found. Do you have any tips here? I tried the way you described above for this...
Read more >Configuring package.json · Jest
Jest's configuration can be defined in the package.json file of your project ... moduleDirectories [array<string>]; moduleNameMapper [object<string, string>] ...
Read more >Configuring Jest
Alternatively Jest's configuration can be defined through the "jest" key in the package.json ... moduleNameMapper [object<string, string | array<string>>].
Read more >Resolve | webpack
object. Create aliases to import or require certain modules more easily. For example, to alias a bunch of ... [string] values are supported...
Read more >9 JEST Configuration Parameters for testing your React App
These 9 JEST configuration parameters help make testing React applications easier. ... moduleNameMapper [Object] (Default: null).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Or actually, you should be good with https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
@lukaszkalemba yup, you have a few examples listed here: https://jestjs.io/docs/en/configuration#modulenamemapper-objectstring-string--arraystring