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.

babel-plugin-module-resolver aliases + jest watch bug

See original GitHub issue

Here is the demo repo: https://github.com/cloud-walker/jest-module-resolver-bug steps to reproduce the bug are listed in the readme file.

What is the current behavior? jest --watch -o will ignore deps imported using babel-plugin-module-resolver

What is the expected behavior? I’m not sure if its possible, maybe I have to use the moduleNameMapper trick to make it work instead, but maybe it could work, so I’m notifying it.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
thymikeecommented, May 25, 2018

Jest will not make assumptions on aliases based on the babel plugins you use. You’ll need to tell Jest how to resolve these absolute aliases using moduleNameMapper:

  "jest": {
    "moduleNameMapper": {
      "@/(.*)": "<rootDir>/source/$1"
    }
  }

You’ll also need to remove empty jest.config.js because Jest prioritizes it over package.json

1reaction
Ore4444commented, Apr 5, 2020

why is this closed? I’m facing the same issue. It makes much more intuitive sense for alias configuration to be inherited from babel config when babel-jest is used

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue.js - babel-plugin-module-resolver doesnt work with jest
i add moduleNameMapper to jest config, but he work only when i remove babel-plugin-module-resolver and add alias in webpack.
Read more >
babel-plugin-module-resolver | Yarn - Package Manager
This plugin allows you to add new "root" directories that contain your modules. It also allows you to setup a custom alias for...
Read more >
babel-plugin-module-alias - Bountysource
Rewrite/Resolve require/import paths to different values in Babel. Become a Bounty Hunter
Read more >
babel-plugin-module-resolver - NPM Package Overview - Socket
Start using Socket to analyze babel-plugin-module-resolver and its 5 ... to setup a custom alias for directories, specific files, or even other npm...
Read more >
avajs/ava - Gitter
How is it possible to see console.log output from inside the function that is being tested ... Thank a lot! babel-plugin-module-resolver resolve my...
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