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

Breaking changes: pathsToModuleNameMapper resolve path mapping with path.join #1982

Closed
splincode opened this issue Sep 24, 2020 · 8 comments · Fixed by #1989
Closed

Breaking changes: pathsToModuleNameMapper resolve path mapping with path.join #1982

splincode opened this issue Sep 24, 2020 · 8 comments · Fixed by #1989

Comments

@splincode
Copy link

🐛 Bug Report

@ahnpnl Hi, I see this PR
#1969

But this incorrect work when we usage parent directory
After upgrade my test failed
Angular-RU/angular-ru-sdk#172

To Reproduce

we usage ../ in paths

{
    "compilerOptions": {
        "rootDir": ".",
        "baseUrl": "./",
        "module": "esnext",
        "outDir": "./dist/out-tsc",
        "target": "es5",
        "typeRoots": ["../../node_modules/@types", "./"],
        "lib": ["es2018", "dom"],
        "paths": {
            "@angular-ru/logger": ["dist/library"],
            "@angular-ru/common": ["../common/dist/library"],
            "@angular-ru/common/*": ["../common/dist/library/*"]
        }
    }
}

My test for correct behavior work with pathsToModuleNameMapper (ts-jest < 26.4.0):
https://github.com/Angular-RU/angular-ru-sdk/blob/master/packages/jest-utils/integration/tests/simple.spec.ts#L36

Expected behavior

https://github.com/kulshekhar/ts-jest/pull/1969/files#diff-0896c7082173d4fb5357a023b5205b17R10

could you add another test?

https://github.com/Angular-RU/angular-ru-sdk/blob/master/packages/jest-utils/tsconfig.json#L14
where are you referring to the parent directory?

@splincode
Copy link
Author

Also repro:

$ git clone https://github.com/Angular-RU/angular-ru-sdk.git
$ cd angular-ru-sdk
$ yarn install
$ cd packages/jest-utils/
$ # edit package.json (update to ts-jest 26.4.0)
$ yarn build:lib
$ yarn test # see debug

image

Expected

[DEBUG]:  {
    "^@mock/(.*)$": "<rootDir>/integration/tests/helpers/$1",
    "^@angular\\-ru/common$": "<rootDir>/../common/dist/library",
    "^@angular\\-ru/common/(.*)$": "<rootDir>/../common/dist/library/$1"
} 

@ahnpnl
Copy link
Collaborator

ahnpnl commented Sep 24, 2020

hi, thank you for your report. I will look into it. Apparently it is a regression

@ahnpnl ahnpnl added Regression 💥 and removed Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels Sep 24, 2020
@ahnpnl
Copy link
Collaborator

ahnpnl commented Sep 24, 2020

Hmm do you think we can have a logic that, if path starts with . (like your case) then simply append path (which is in 26.3.0), otherwise use path.join

It looks to me like the problem with #1968 only happens when the path doesn’t start with .

@splincode
Copy link
Author

@ahnpnl It looks to me like the problem with #1968 only happens when the path doesn’t start with .

not sure, but if we will have test for this case then I would be sure of it

@ahnpnl
Copy link
Collaborator

ahnpnl commented Sep 28, 2020

hi @splincode , I have published 26.4.1-alpha.0. Would you please try and see if it fixes the issue ? You can try this alpha version when installing ts-jest@next

@splincode
Copy link
Author

thank you 🙏 I will try latter

@splincode
Copy link
Author

@ahnpnl Works for me )) thank you)

@ahnpnl
Copy link
Collaborator

ahnpnl commented Sep 28, 2020

Thank you for your help with testing. 26.4.1 will come shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants