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

docs(paths-mapping): Fixed broken guide for paths mapping helper #3894

Merged
merged 1 commit into from
Nov 7, 2022

Conversation

seongbin9786
Copy link
Contributor

@seongbin9786 seongbin9786 commented Nov 4, 2022

Summary

Hi! I'm a newcomer to ts-jest, had a problem setting up test environment for my project using this library.

TypeScript Alias using tsconfig.json didn't work in test files.

I was wondering for around 30 minutes and found the answer from the Issue's comment - which was at the bottom of the page. It seemed really hard to find the information.

This PR provides "helper" part of "Paths Mapping" documentation page the missing code.

As this Issue's comment states, the documentation should state as follows to make jest config work with aliases from tsconfig:

module.exports = {
  // [...]
  roots: ['<rootDir>'],
  modulePaths: [compilerOptions.baseUrl], // <-- This will be set to './src'
  moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths /*, { prefix: '<rootDir>/' } */),
}

FYI, the documentation was as follows(as you can see from commit):

  // [...]
  moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths /*, { prefix: '<rootDir>/' } */),
}

Test plan

Not needed.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

None.

@seongbin9786 seongbin9786 changed the title docs(paths-mapping): Fixed broken guide for mapping helper docs(paths-mapping): Fixed broken guide for pahts mapping helper Nov 4, 2022
@coveralls
Copy link

coveralls commented Nov 4, 2022

Pull Request Test Coverage Report for Build 3391529444

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.008%) to 95.861%

Totals Coverage Status
Change from base Build 3351485920: 0.008%
Covered Lines: 4055
Relevant Lines: 4154

💛 - Coveralls

@coveralls
Copy link

coveralls commented Nov 4, 2022

Pull Request Test Coverage Report for Build 3410044521

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 95.819%

Totals Coverage Status
Change from base Build 3351485920: -0.03%
Covered Lines: 4055
Relevant Lines: 4154

💛 - Coveralls

@seongbin9786 seongbin9786 changed the title docs(paths-mapping): Fixed broken guide for pahts mapping helper docs(paths-mapping): Fixed broken guide for paths mapping helper Nov 4, 2022
@seongbin9786 seongbin9786 requested review from ahnpnl and removed request for kulshekhar November 5, 2022 00:11
Copy link
Collaborator

@ahnpnl ahnpnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@ahnpnl ahnpnl merged commit f45cc08 into kulshekhar:main Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants