2

I am running a Karma/Jasmine on Angular 4 CLI environment. Sadly my tests do not allow me to debug in typescript as per the following link: [https://angular.io/guide/testing#test-debugging][1]

My project was setup by Angular/CLI and upgraded from Angular2 to 4, and is on a Windows 10 computer.

Phil Huhn
  • 3,307
  • 3
  • 18
  • 35

1 Answers1

0

I have a simple angular\cli project. Initial created the project with @angular/cli 1.0.2. When I run 'npm run test' the chrome browser launches and runs my jasmine test cases. At the very top of the page is a large 'DEBUG' button. Clicking this button with launch a 2nd page of tests. If you open the developer tools (f12), navigate to sources there is a folder called "webpack://". In the webpack folder there is a "." folder. This is your project folder and you should recognize you source code. At this point you can debug anything you want. i.e. the .spec.ts or the .ts files. Simply set a break point and refresh the page.

I recently upgraded to @angular/cli 1.1.3 when I did this my webpack folder disappeared. I have not been able to find where to debug with this latest version. I imagine there is most likely a version between 1.0.2 and 1.1.3 that still has the webpack folder but I have not found it yet. I have latest versions of everything else. i.e. @angular 4.2.4.

So until I figure out how to debug with @angular/cli 1.1.3 + I will be sticking with @angular/cli 1.0.2

  • If you run ***npm test***, it will run ***ng test***. With this implementation of karma, the application is bundled and that seems to be at the root of my issue/question, and it appears, you have also found it to be true. – Phil Huhn Jun 26 '17 at 21:12
  • My ng environment is as follows: @angular/cli: 1.1.2 node: 6.11.0 os: win32 x64 @angular/core: 4.2.3 – Phil Huhn Jun 28 '17 at 22:58
  • Sourcemaps for tests broken since 1.1.2 #6824, https://github.com/angular/angular-cli/issues/6824 – Phil Huhn Jun 30 '17 at 00:12
  • #6824 has been closed as duplicate, the proper thread is Test source maps are not working #6737 [link]https://github.com/angular/angular-cli/issues/6737 – Phil Huhn Jul 03 '17 at 15:08