Configuration runner acts like it runs in a different directory than terminal
I have a configuration that is just supposed to run the following script:
ng test time-and-pay-calculator
When I run the configuration, it doesn't find any tests or even any files with tests. When I run the same script in the terminal, it behaves as expected. When I look at the configuration screen it says that the working directory is the same directory as my terminal is.
I have been spinning my wheels on this for about a week now and would really like to figure this out. Any help is much appreciated
请先登录再写评论。
Does this happen with all your scripts, or this specific one only? What does your run configuration look like?
Please add
console.log("current dir is " + process.cwd());
to the code that is being run by this script and check the results when running it with the run configuration and in terminal.It only happens with Jest configurations/commands. This is the result of the command as run by webstorm's configuration runner:
Whereas the terminal finds 200+ tests in 23 suites (the expected behavior)
What does your run configuration look like? What test builder is specified in the angular.json?
I currently have the @angular-builders/jest:run builder specified as the official angular builder is not available neither is there one available for ngx-build-plus.
As for the configuration, this is what I have currently. Some things I have tried are changing the jest package to either the installed jest or jest-cli packages however these both result in the transforms being run incorrectly.
I can see that you are passing a project name to
ng test
; is it an Angular workspace with multiple projects/libraries? if yes, does specifying the project subdirectory instead of the workspace root as a working directory helps?In the terminal there is no difference. I also can't seem to figure out how to disable that. In any case, no. This project is only the one project no other apps are involved
Could you share a project that reproduces the issue?
I just recreated the issue in a different repo. That repo is here: https://github.com/DuncanMcPherson/jest-test
Thank you for the test repo!
Unfortunately, the problem can not be reproduced on our side in the project you’ve shared:
Here is my run configuration (the one that was auto-created from the gutter, I didn't modify it in any way):
What IDE version do you work with?
I use 2023.3.4. I do have the option of 2024.1 EAP but the EAP was buggy the last time i tried it so i rolled back
I am checking to see if it is Node or my version of Angular. barring that, I am going to try a clean install of webstorm. otherwise it might just be my machine.
Ok, I have verified it isn't the version of node, or angular. On a clean install I still see the same behavior. I will try later on a different machine to see if it is just my computer.
Thanks for the help! It turns out it wasn't an issue on my other machine. I am not sure what was causing the issue and I didn't have a ton of important things on my laptop anyways so I reimaged it and now everything works just fine.
Great, thanks for update!