-
Notifications
You must be signed in to change notification settings - Fork 8
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
Yarn workspace root path normalization #30
Comments
@nason good find! Although I think you should be running tests locally to each package, this is probably something that can be relatively easily supported for both I think each workspace should use Regarding the PR, tests will need to be added, which I don't mind helping with at all, as well as parse I'm not sure about using Also, there can be multiple yarn workspaces within the same project. We'll need to handle that as well. We'll probably want to add a separate test command that runs all existing tests inside a skeleton Am I missing anything? @tribou thoughts? |
Yes, I agree this would be a great use case and support what @chrisblossom mentioned. I'm not well-versed with
Feel free to provide any additional input, but it looks like these are the tasks needed to merge:
|
This could mean rewriting the
This is only if people use the Also, it should be noted that @nason What do you think of all that we've discussed so far? |
@nason If you don't have the time for this please let me know. I'll start working on it if not, no problem at all either way. |
Unless we find a good, simple, side effect-free way to detect @chrisblossom in the majority of projects you've seen where they don't use |
@tribou It is just as easy supporting I'll try and put something together soon, although my free time is currently limited for a month or so. |
I'm now thinking it is better to not handle For example: const path = require('path');
const file = 'packages/test-pkg/src/index.js';
const absolutePath = path.resolve(process.cwd(), file); // <PROJECT_ROOT>/src/index.js
const relativePath = path.relative(process.cwd(), file); // packages/test-pkg/src/index.js |
Hey @chrisblossom, I'm not 100% sure I'll have time this week but I will do my best to get on this and will leave any updates I have here. I have snapshot tests disabled in my project until this is resolved so I'd really love to land a fix here 🎈
Can you explain what you mean? I'm not sure I follow. Let me try to rephrase the issue I was seeing: Before moving to a workspace, this serializer made all paths relative to the project root so that snapshots were nicely portable. After moving to a workspace, the serializer does not seem to detecting a project root (or a workspace root, as suggested above) and outputs paths relative to my home directory, resulting in non-portable snapshots. |
@nason I am unsure why you are seeing I've created a minimal repo that showcases Please send a PR to that repo or create a minimal repository to show what you are seeing.
My code block in #30 (comment) shows the comments of the result. You can see relative paths will be different than absolute paths, which I do not think this is expected / wanted. Another issue with directly supporting Lots of random edge cases here. BTW, |
Hi there,
Thanks for this handy module. I've been using it within a shared build tool with great effect. We're looking into moving into a Yarn Workspace setup and I noticed that this serializer does not handle normalization of the yarn workspace root path.
For example, in a non-workspace setup a path that was
~/code/single-project/node_modules/foo/foo.js
would correctly normalize to<PROJECT_ROOT>/node_modules/foo/foo.js
However, in a Yarn workspace this may resolve to to
~/code/workspace/node_modules/foo/foo.js
(the project in this case lives at~/code/workspace/packages/single-project
), which gets normalized as<HOME_DIR>/code/workspace/node_modules/foo/foo.js
. Ideally, this would be relative to the workspace root (something like<WORKSPACE_ROOT>/node_modules/foo/foo.js
) so that our tests are not dependent on a specific project location.I took a very quick pass at this in https://github.com/tribou/jest-serializer-path/compare/master...nason:yarn-workspace-support?expand=1. It seems to be working for me, but wanted to get your thoughts on this before going any further.
The text was updated successfully, but these errors were encountered: