-
Notifications
You must be signed in to change notification settings - Fork 125
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
Support cwd of current package inside monorepo #353
Comments
similar issue here with monorepo, its cwd is down in the root. An option to specify the directory through a configuration option so I can use something like a vscode variable reference would help. |
From vscode-jest-runner/src/jestRunnerConfig.ts Lines 64 to 74 in 81b797c
So the current fallback logic for
Would it make sense to change (2) to find packages with either |
i forgot we already have such a logic. it seems like if we also check for vitest it would solve the issue? |
Adding support for The problem described here is that dependency hoisting causes jest/vitest to be installed in a different location than where it should be used. For example, the directory layout might look like this:
jest is only listed as a dependency in If
So vscode-jest-runner would now run the tests inside the respective module folders. Personally I don't see a use case where in the first case (both modules using the same jest version) the tests should run on the root level of the project. So my recommendation would be to simply remove the check for |
This is my exact issue as well. Also, agree that it seems like this would work as the default. But would be happy with an option. |
I am using this plugin in a monorepo with several modules. In my case, I have configured
jestrunner.jestCommand
to beyarn test
(which in my case executesvitest
instead ofjest
).By default, vscode-jest-runner executes the command on the root level of my monorepo. I would like it to execute on the root level of the individual NPM package instead, for several reasons:
jest
(or in my casevitest
) installed on the root levelyarn test
command might be different for each moduleSince #156, the project path is automatically detected based on where a
package.json
file and anode_modules/.bin/jest
file is present. In case of a monorepo, this will only result in my desired behaviour if the modules have different versions of jest installed. If they all have the same version,node_modules/.bin/jest
will be available on the root level of the repo.As a workaround, I currently have
jestrunner.changeDirectoryToWorkspaceRoot
set tofalse
and manuallycd
into the appropriate directory in thejest
terminal before running the tests.One way this could be achieved would be to add a config option (such as
jestrunner.changeDirectoryToPackageRoot
) thatcd
s to the nearest ancestor directory containing apackage.json
file before running a test.On the other hand, I'm wondering whether this behaviour shouldn't be the default. The location detection for the
eslint
executable would stay the same as today, but the detection of the cwd would become independent of that and use the closest ancestor directory containing apackage.json
. Are there any setups that this would break?The text was updated successfully, but these errors were encountered: