You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm creating this to re-open #31159. The reproduction of the issue is still present in the with-jest example on the canary branch. If the "moduleNameMapper" section in jest.config.js is removed, jest won't find the "paths" field in tsconfig.json/jsconfig.json and is documented as such in both the example, and in the next testing documentation(ctrl+f "Optional: Absolute Imports and Module Path Aliases")
Describe the solution you'd like
next/jest should automatically fill the the "moduleNameMapper" field if paths if filled out in tsconfig.json.
Describe alternatives you've considered
There's the ts-paths package, and (as linked in #31159) the babel-plugin-module-resolver package. I used a home grown solution that's mostly lifted from the ts-jest
The text was updated successfully, but these errors were encountered:
<!--
Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:
-->
# Description
fixes#31159fixes#44553
Path aliases defined in `tsconfig.json` or `jsconfig.json` are not
automatically configured to work with Jest. This means that these
aliases have to be defined in multiple places.
This PR configures the SWC Jest transform to handle the `baseUrl` and
`paths`, so that users don't need to configure a `moduleNameMapper` for
Jest.
~This PR intends to make the experience more seamless by automatically
configuring Jest's `moduleNameMapper` and `moduleDirectories` based on
the settings in a project's `tsconfig`/`jsconfig`.~
~Users will be able to supply their own configuration for these fields,
if they have use-cases that require manual configuration.~
~The implementation is taken from the [`paths-to-module-name-mapper`
function in
`ts-jest`](https://github.com/kulshekhar/ts-jest/blob/5a0880add0da8d71900eee20c7642e6be65f6a66/src/config/paths-to-module-name-mapper.ts).~
## Bug
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
## Feature
- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [x] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
## Documentation / Examples
- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
Describe the feature you'd like to request
I'm creating this to re-open #31159. The reproduction of the issue is still present in the
with-jest
example on the canary branch. If the "moduleNameMapper" section injest.config.js
is removed, jest won't find the "paths" field intsconfig.json
/jsconfig.json
and is documented as such in both the example, and in the next testing documentation(ctrl+f "Optional: Absolute Imports and Module Path Aliases")Describe the solution you'd like
next/jest
should automatically fill the the "moduleNameMapper" field ifpaths
if filled out intsconfig.json
.Describe alternatives you've considered
There's the
ts-paths
package, and (as linked in #31159) thebabel-plugin-module-resolver
package. I used a home grown solution that's mostly lifted from thets-jest
The text was updated successfully, but these errors were encountered: