The level of logging by karma can be changed in the karma.conf.js file.
Go to karma.conf.js and add/change the property logLevel to config.LOG_DISABLE if you don't want to see any logs or config.LOG_ERROR if you want to only see the errors. Like this:
module.exports = function (config) {
config.set({
...,
logLevel: config.LOG_ERROR,
...,
})
}
If you are running karma from the command line you can append --log-level debug to the command for the same effect.
» npm install @ng-lv/logging
Update for Angular version 9
The source files have been moved but you can still debug this way if you do the following steps
- In devtools, select the sources tab
- Press CTRL + P
- Type in the name of the file you want to debug

Valid for versions below 9
The other answers are completely valid answers but having been using Angular for around 18 months now I tend to do it in the browser - chrome tools!
Run ng test then f12 and find the spec file via the webpack context. Add a breakpoint(s) and refresh and it will hit said breakpoints. As per screenshot
This is what worked for me with:
- Angular 9.0.6 + Visual Studio Code 1.43.2
- Angular 8.2.13 + Visual Studio Code 1.39.2
- Angular 7, Angular CLI 1.0.* and Chrome on Windows 7.
Change configuration files
In your project root directory open karma.conf.js. Right after singleRun: false add , followed by this section:
customLaunchers: {
ChromeDebug: {
base: 'Chrome',
flags: [ '--remote-debugging-port=9333' ]
}
}
Add configuration to .vscode/launch.json.
For versions 8.* - 9.* (note
"pathMappingsection!):{ "type": "chrome", "request": "attach", "name": "Unit tests", "address": "localhost", "port": 9333, "sourceMaps": true, "webRoot": "${workspaceFolder}", "pathMapping": { "/_karma_webpack_": "${workspaceFolder}" } },For version 7.*:
{ "type": "chrome", "request": "attach", "name": "Unit tests", "address": "localhost", "port": 9333, "sourceMaps": true, "webRoot": "${workspaceFolder}" },
Start debugging
Run
ng test --browsers ChromeDebugWait for Chrome browser to start. You will see something like this in command line:
01 06 2017 16:07:29.276:INFO [launcher]: Launching browser ChromeDebug with unlimited concurrencySet the breakpoint in one of your
.spec.tsfiles.In Visual Studio Code choose
Unit testsdebug configuration and hit F5 ("Start Debugging" button).Press
Shift+Ctrl+F5or refresh the Chrome window to rerun the tests and hit the breakpoint.
For convenience
You can also modify your package.json and add a new script:
"test-debug": "ng test --browsers ChromeDebug",
Then next time you want to start ng test with debugging just run:
npm run test-debug
References:
- Debugging Jasmine Unit tests running with Karma runner in VS Code
- Debugging Karma tests with VSCode
- Angular CLI 8.1.3
Debug Unit Testsconfiguration - Unverified breakpoint - microsoft/vscode-recipes - Chrome Debugging with Angular CLI
» npm install ng-logger
» npm install ngx-logger
I found a workaround for this. Create your custom logging.properties in src/test/resources, then in a setup call, load it up as such:
@BeforeClass(alwaysRun = true)
protected void setUp() throws SecurityException, IOException
{
FileInputStream fis = new FileInputStream(BaseRestTest.class.getResource("/logging.properties").getFile());
LogManager.getLogManager().readConfiguration(fis);
}
This appears to re-configure the root logger after TestNG has pillaged it.
Mike,
You can adjust the log level in testng.xml:
<suite verbose="3"... (up to 10)
TestNG doesn't use Log4J nor java.util.logging.
Although you can't log dom/web events in the console that don't cause server requests, you can increase the amount of information that the compilation process and static web server provide by passing a --verbose flag when starting up: ng serve --verbose.
Also, if you're running a proxy a server to hit a local API server and you want some more logging regarding how those requests are being proxied, you can increase the logLevel in your proxy configuration.
Example proxy.conf.json:
{
"/api": {
"target": "http://localhost:3001",
"secure": false,
"logLevel": "debug"
}
}
You would then be starting the server as ng serve --proxy-config proxy.conf.json --verbose.
You can't make your angular code log to the shell that started ng serve, sorry :-(
You will only see build errors in that console