I was looking for something similar, and found this: https://github.com/usrz/javascript-karma-verbose-reporter. Generates this kind of output:

$ karma start --reporters=verbose

Suites and tests results:

 - the app.router.config module :
   * contains a router property : ok
   * configures the router title : ok
   * should have a login route : ok
 - the organization module :
   * contains a state property : ok
   * should have a streams route after configuration : ok
   * when activated, should set state based on organization in route : ok
 - the streams module :
   * points to state : ok
   * loads organization streams upon activation : ok
   * loads organization streams via API : ok

Browser results:

 - PhantomJS 1.9.8 (Mac OS X 0.0.0): 9 tests
   - 9 ok

To make this a default option, you can add this to your karma config, e.g.:

reporters: ['verbose', 'junit']
Answer from Carles Barrobés on Stack Overflow
🌐
Angular
angular.dev › cli › test
ng test • Angular
Specifies the reporters to use during test execution. Each reporter can be a string representing its name, or a tuple containing the name and an options object. Built-in reporters include 'default', 'verbose', 'dots', 'json', 'junit', 'tap', ...
🌐
Stack Overflow
stackoverflow.com › questions › 71775547 › how-to-get-more-verbose-output-from-ng-test-configuration
angular - How to get more verbose output from "ng test" configuration - Stack Overflow
Finally got past my problem by using ng-cli to bootstrap a new project and isolating one simple spec file to run there (had around 120 tests in a project that used Angular4 and angular-seed).
🌐
TutorialsPoint
tutorialspoint.com › angular_cli › angular_cli_ng_test.htm
Angular CLI − ng test Command
If you have multiple Angular projects in a workspace, you can specify which project tests to run. options: Various flags or configurations you can use to modify the behavior of the command. Note! You can also use its shorthand form "ng t", where "t" stands for "test".
🌐
Angular
v17.angular.io › cli › test
ng test
Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular.
🌐
Testing-angular
testing-angular.com › debugging-tests
Debugging tests – Testing Angular
February 17, 2021 - In this case, you can instruct ng test to consider only the file you are currently working on.
🌐
GitHub
github.com › angular › angular-cli › issues › 9757
[Documentation Request] ng test --log-level options · Issue #9757 · angular/angular-cli
February 23, 2018 - On the page here I am unable to actually find any log levels. My Googling has failed me when I tried to find any information on the subject. Desired behavior What would like to see implemented + what did you expect to see: The values ava...
Author   DinoSourcesRex
Top answer
1 of 6
71

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

2 of 6
47

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 "pathMapping section!):

    {
      "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

  1. Run ng test --browsers ChromeDebug

  2. Wait 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 concurrency
    
  3. Set the breakpoint in one of your .spec.ts files.

  4. In Visual Studio Code choose Unit tests debug configuration and hit F5 ("Start Debugging" button).

  5. Press Shift+Ctrl+F5 or 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 Tests configuration - Unverified breakpoint
  • microsoft/vscode-recipes - Chrome Debugging with Angular CLI
🌐
Angular
v17.angular.io › guide › test-debugging
Angular
Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular.
Find elsewhere
🌐
W3Resource
w3resource.com › angular › ng-test.php
Angular - ng test - w3resource
ng test <project> [options] ng t <project> [options] ... Takes the name of the project, as specified in the projects section of the angular.json workspace configuration file.
🌐
YouTube
youtube.com › watch
24. Testing Angular Application using ng test command and pass all the tests - Angular CLI - YouTube
In this video we will see how to test the Angular application using ng test command and pass all the tests in the application - Angular CLI.If you like my vi...
Published   December 14, 2021
🌐
GitHub
github.com › angular › angular-cli › issues › 11086
Unknown option: '--verbose' · Issue #11086 · angular/angular-cli
June 1, 2018 - Versions Angular CLI: 6.0.7 Node: 8.9.0 OS: win32 x64 Angular: 6.0.3 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dy...
Author   mnicic
🌐
GitHub
github.com › angular › angular-cli › issues › 1246
ng test logging · Issue #1246 · angular/angular-cli
June 29, 2016 - Is it possible to output · ng test --watch=false --build=false
Author   kamran-pervaiz
🌐
Angular
docs.angular.lat › guide › testing
Visión general • Angular
✓ src/app/app.spec.ts (3) ✓ AppComponent should create the app ✓ AppComponent should have as title 'my-app' ✓ AppComponent should render title Test Files 1 passed (1) Tests 3 passed (3) Start at 18:18:01 Duration 2.46s (transform 615ms, setup 2ms, collect 2.21s, tests 5ms) El comando ng test también observa cambios.
🌐
Pluralsight
pluralsight.com › tech insights & how-to guides › tech guides & tutorials
Executing Unit Tests Using the Angular CLI | Pluralsight
August 27, 2020 - The fundamentals you learn in this guide will apply to existing Angular projects that still use the default Angular unit testing framework (Jasmine) and test runner (Karma). Let's get started! The Angular CLI can be downloaded onto your machine by running the following command using NPM: ... You can now use the ng command to access the CLI.
🌐
Angulardoc
angulardoc.com.br › cli › test
ng test - Angular
Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular.
🌐
Automation Panda
automationpanda.com › 2018 › 01 › 15 › missing-error-messages-with-angular-testing
Missing Error Messages with Angular Testing | Automation Panda
January 18, 2018 - I recently had a devil of a time figuring out why my Angular unit tests were broken because error messages were not being printed! Running “ng test –sourcemaps=false” solved the p…