-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Description
Not sure if it's a Node.js or jest-resolve issue, so I'm cross-posting it.
- Version: v15.10.0
- Platform: Linux PRO2 5.8.0-45-generic Nominating Chris Dickinson to the TC #51-Ubuntu SMP Fri Feb 19 13:24:51 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
- Subsystem: packages
What steps will reproduce the bug?
At Node.js packages docs it says it's possible to self-reference and import a package from it's own modules by using the package name, the same was as it's done with dependencies installed on node_modules. I'm self-referencing my package itself in my jest tests, it says it can't find it:
● Test suite failed to run
Cannot find module '@piranna/rpc' from '__tests__/index.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)Since my package has a scope (package name is in the form with @<scope>/<packageName>) and there's no examples or references in Node.js docs about self-referencing scoped packages, maybe this is a Node.js packages resolving algorythm.
How often does it reproduce? Is there a required condition?
It happens me always. Maybe related to jest-resolve package.
What is the expected behavior?
The self-referenced package should be imported.
What do you see instead?
It give an error stating it can't find the module.
Additional information
I'm trying to do it that way in combination with package.json imports and Jest projects and testEnvironment, I can be able to test my code in multiple environments doing different imports for each one, so I can apply polyfills automatically.