question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Comments:13

github_iconTop GitHub Comments

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found