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.

Support for imports with absolute path

See original GitHub issue

Due to issue #58 I found out that unfortunately imports like

import { reposLoaded, repoLoadingError } from 'containers/App/actions';

don’t work with jest and produces next error:

app\containers\HomePage\tests\sagas.test.ts
  ● Test suite failed to run

    Cannot find module 'containers/App/actions' from 'sagas.ts'

      at Resolver.resolveModule (node_modules\jest-resolve\build\index.js:151:17)
      at Object.<anonymous> (app\containers\HomePage\sagas.ts:8:19)
      at Object.<anonymous> (app\containers\HomePage\tests\sagas.test.ts:7:17)

While normal imports with relative paths behave as expected. It could be problem of jest-resolve module, but we have to try to solve it inside ts-jest or find what exactly causes this problem in jest-resolve. As always we have to start from tests for this case.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:22
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

133reactions
mohsen1commented, Dec 1, 2016

I don’t see anywhere this module passing options to jest-resolve. Putting the extra moduleDirectories in package.json jest object works for my case:

"jest": {
    "moduleDirectories": ["node_modules", "src"],
8reactions
marcusjwhelancommented, May 2, 2017

What if this is still an Issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understand and Configure Absolute Import Paths in JavaScript
An absolute import path is a path that starts from a root, and you need to define a root first. In a typical...
Read more >
Advanced Features: Absolute Imports and Module Path Aliases
Configure module path aliases that allow you to remap certain import paths. ... Next.js automatically supports the tsconfig.json and jsconfig.json "paths" ...
Read more >
Use Absolute Paths with React - Better Programming
By default, relative paths are the supported way of importing modules to React and other frameworks. You will usually see or write something ......
Read more >
Making Life Easier with Absolute Imports - React in Javascript ...
According to create-react-app Docs, We can use absolute imports in our react project by configuring a jsconfig. json / tsconfig. json (for ...
Read more >
Absolute vs Relative Imports in Python
An absolute import specifies the resource to be imported using its full path from the project's root folder. Syntax and Practical Examples. Let's...
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