Karma Test Explorer in VS Code fails to load tests: “karma server quit unexpectedly”

Hey! This post is to capture the non-obvious debugging steps needed to resolve the following error:

At one point in our project development, team members started to notice that the Karma-based front-end tests stopped loading in the Karma Test Explorer plugin:

A manifestation of the problem: front-end unit tests were no longer listed in Visual Studio Code.

The error was not clear, but we got some more information when we looked in the output for the “Test Explorer” addon:

The output of the “Test Explorer” add-on says a bit more, but it is not enough to understand the issue.

The key finding that allowed us to pinpoint the issue was that Visual Studio Code keeps logs for all addons in the filesystem, even if they are not reachable from the IDE itself. The path might be different on your machine, but look for a folder like this:

In our case, the solution lay in the file named 2-Karma Test Explorer (workspace).log and was related to using // comments syntax in the angular.json file which Karma didn’t like:

Your problems most likely have a different root cause than mine, but hopefully, with the knowledge of where to look, you find the issue faster. Good luck!

No comments yet, you can leave the first one!

Leave a Comment