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.

5
  • In chrome Developer Tools under source tab check is there any webpack folder? Commented Jun 24, 2017 at 21:35
  • Yes, karma_webpack, containing 4 bundle javascript files. Commented Jun 25, 2017 at 0:09
  • U r running the application using ng serve? Commented Jun 25, 2017 at 6:09
  • Yes, I'm running the application using ng serve and karma by ng test. Vanilla CLI configuration. Commented Jun 25, 2017 at 13:21
  • Please refer to this answer: stackoverflow.com/a/51443584/6923507 Commented Jul 20, 2018 at 13:53

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

4 Comments

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.
My ng environment is as follows: @angular/cli: 1.1.2 node: 6.11.0 os: win32 x64 @angular/core: 4.2.3
Sourcemaps for tests broken since 1.1.2 #6824, github.com/angular/angular-cli/issues/6824
#6824 has been closed as duplicate, the proper thread is Test source maps are not working #6737 [link]github.com/angular/angular-cli/issues/6737

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.