Support project without angular-cli
chudzikmagda opened this issue · 11 comments
I have a project based on Angular but I don't use an Angular CLI. Is it possible to treat it as Karma project (not Angular) even that I have a angular.json file in root directory?
@chudzikm:
- From the command line, are you able to successfully run your tests using only the Karma command
npx karma start <path_to_karma_conf> --single-run
? - Also, as a quick test, set the
karmaTestExplorer.logLevel
setting todebug
, rename yourangular.json
file to something different and restart VSCode. Is Karma Test Explorer (which will now see it as a plain Karma project) able to successfully discover and run your tests? (Please attach theKarma Test Explorer
andKarma Server
debug logs from the Output panel).
I've tested a few configurations more. Without angular.json it works fine. It would be helpful to have a possibility to treat the project with angular.json as 'the Karma project'.
@lucono, what do you think about an idea of adding a new feature /treating project with angular.json as 'Karma project'/ to your plugin?
@chudzikm sounds like a good addition. The change is also relatively trivial. I've added it to a number of other fixes intended for v0.5.0 which are on the beta branch. The new setting is karmaTestExplorer.projectType
and will let you override the project type. Test it out to confirm if it addresses the issue. You can download the .vsix
artifact from the CI build of the beta
branch, or build it yourself directly from the branch.
@lucono thank you :) I've tested it and it works fine. I have one more idea. What do you think of loading this property from the package.json of the project instead of adding it to the user settings?
@chudzikm Rather than add them to your user settings, you can use workspace settings instead to keep them within your project (like the one in this repo).
Yes, but I was thinking about a solution that does not depend on IDE and users don't have to do anything 😉.
I have another question. What about a project that have a Karma installed not from package.json in the root directory?
I was thinking about a solution that does not depend on IDE and users don't have to do anything
@chudzikm Verifying that the Angular dependency exists in package.json
before selecting it as the project type makes sense. If you'd like to submit a PR, I'd be willing to review and release it.
What about a project that have a Karma installed not from package.json in the root directory?
Do you mean a project using Karma installed globally, or just from a package.json
file in a different location? If the former, there's a karmaTestExplorer.allowGlobalPackageFallback
setting which might provide what you need.
I thought about Karma installing from package.json file from a different location.
Karma Test Explorer expects the package.json
file to be in the project root given that this is also a normal default expectation for JavaScript projects. In edge cases where that is not the case, the new projectType
setting, and existing allowGlobalPackageFallback
setting, provide a good amount of flexibility to still make things work as desired.
@lucono thanks for your help.