Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for imports with absolute path #64

Closed
Igmat opened this issue Nov 28, 2016 · 10 comments

Comments

@Igmat
Copy link
Contributor

commented Nov 28, 2016

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.

@mohsen1

This comment has been minimized.

Copy link

commented Dec 1, 2016

Will passing the baseUrl in tsconfig.json to jest-resolve moduleDirectories do this?

@mohsen1

This comment has been minimized.

Copy link

commented Dec 1, 2016

Yup, manually overriding moduleDirectories in jest-resolve module worked for me. Putting together a pull request.

@mohsen1

This comment has been minimized.

Copy link

commented 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"],
@Igmat

This comment has been minimized.

Copy link
Contributor Author

commented Dec 2, 2016

@mohsen1, thank you fro your investigation and moving issues to Jest itself.
I guess we have to add your current workaround to readme and close this issue, because it's not related to ts-jest.
Is it would be ok for you?

@mohsen1

This comment has been minimized.

Copy link

commented Dec 2, 2016

Yes. Just adding that config option works.

Igmat added a commit that referenced this issue Dec 2, 2016
@Igmat

This comment has been minimized.

Copy link
Contributor Author

commented Dec 5, 2016

Closed due to #77

@Igmat Igmat closed this Dec 5, 2016
@marcusjwhelan

This comment has been minimized.

Copy link

commented May 2, 2017

What if this is still an Issue?

@kulshekhar

This comment has been minimized.

Copy link
Owner

commented May 2, 2017

@marcusjwhelan the best would be to create a minimal repo that reproduces this and open a new issue with a link to the repo

@marcusjwhelan

This comment has been minimized.

Copy link

commented May 2, 2017

@kulshekhar , would this repo be too large? binary-type-tree. It really only has to do with the tsconfigs and package.json

@kulshekhar

This comment has been minimized.

Copy link
Owner

commented May 2, 2017

@marcusjwhelan it's better than nothing :)

That said, the smaller a repo is, the quicker the issue is likely to be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.