-
Notifications
You must be signed in to change notification settings - Fork 453
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
type script reference path is not getting resolved in jest #1523
Comments
Its something out of scope for jest # jestjs/jest#9805 |
You can try moduleNameMapper in jest config. The error is about jest can’t find your file with that path. This issue is not ts-jest issue. |
I have tried with moduleNameMapper |
you need to set proper In general, when using |
ok, i did, it too did not work. |
why don't you point to |
unfortunately, I don't see the corresponding .ts file. I found only the .d.ts file where all the classes are getting export https://github.com/grafana/grafana-sdk-mocks/blob/master/app/headers/common.d.ts |
hmm do you mind share a minimum repo so I can take a look ? :) |
https://github.com/pallabrath/ts-jest-Issue1523 |
ok I found workaround for your case.
Explanation
Can you please try ? |
Thanks .. Its working now @ahnpnl you are awsome 💯 |
I will close this by a proper fix, for now you can use that workaround 👍 |
@pallabrath I just checked your problem against |
Hi @pallabrath , you can use |
In one of the ts file (query_ctrl.ts) the module import are like below
///
import { QueryCtrl } from 'app/plugins/sdk';
export class MyQueryCtrl extends QueryCtrl
{ .....
In module.ts
export {
MyQueryCtrl as QueryCtrl
};
While in jest test module.test.ts
import { QueryCtrl } from '../../datasource/module'
● Test suite failed to run
Cannot find module 'app/plugins/sdk' from 'query_ctrl.ts'
Require stack:
src/datasource/query_ctrl.ts
src/datasource/module.ts
src/specs/datasource/module.test.ts
6 | import { Utils } from './Utils';
9 |
10 |
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:296:11)
at Object. (src/datasource/query_ctrl.ts:7:1)
jest.config.js
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
coverageDirectory: "work/coverage",
};
The text was updated successfully, but these errors were encountered: