Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging ng test doesn't work #9

Closed
weinand opened this issue Jun 28, 2017 · 23 comments
Closed

Debugging ng test doesn't work #9

weinand opened this issue Jun 28, 2017 · 23 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug
Milestone

Comments

@weinand
Copy link
Contributor

weinand commented Jun 28, 2017

From @jrieken on June 27, 2017 8:43

testing #29476

The last step which is about debugging test doesn't work for me. Breakpoints appear as empty circles not discs.

screen shot 2017-06-26 at 16 29 14

Copied from original issue: microsoft/vscode#29539

@weinand
Copy link
Contributor Author

weinand commented Jun 28, 2017

From @chrmarti on June 27, 2017 20:45

Same here on Windows. ng test spawns a Chrome window which is not mentioned in the recipe and the launch config the spawns another window that doesn't trigger the breakpoints.

@weinand weinand self-assigned this Jun 28, 2017
@weinand weinand added bug Issue identified by VS Code Team member as probable bug debug labels Jun 28, 2017
@weinand
Copy link
Contributor Author

weinand commented Jun 28, 2017

The test setup (ng test) seems to have changed in a bigger way: they are now based on karma (which I think they weren't before).

/cc @roblourens @tonysneed

@roblourens
Copy link
Member

Was looking at this with @Lixire, and I couldn't even get sourcemaps loaded in chrome devtools.

@auchenberg
Copy link
Contributor

@tonysneed
Copy link

@weinand I noticed recently that the source maps are an issue again -- this time with ng test.

@weinand
Copy link
Contributor Author

weinand commented Jun 28, 2017

@tonysneed I don't think it's just a source map issue. ng test now spawns a Chrome window which is not mentioned in the recipe. So the whole approach to these tests has changed.

@tonysneed
Copy link

@weinand I don't think the approach has changed in a way that can't be documented in the recipe. ng test still uses Karma like before, and the window that pops up has a debug button on it, which brings up the same url as specified in the test confit in launch.json.

So if the source map issue is resolved, we should be back on track with debugging tests with the chrome debugger extension for vs code. Can we get some input from someone on the A-CLI and/or the debugger extension teams?

@roblourens
Copy link
Member

roblourens commented Jun 29, 2017

I can look into it later but I don't have time this week.

@auchenberg
Copy link
Contributor

Running .scripts with a generated angular-cli 1.1.3 app gives me this


› VM45
› VM47
› VM49
› VM53
› VM55
› VM57
› VM59
› VM61
› VM63
› http://localhost:9876/_karma_webpack_/inline.bundle.js
› http://localhost:9876/_karma_webpack_/main.bundle.js
› http://localhost:9876/_karma_webpack_/polyfills.bundle.js
› http://localhost:9876/_karma_webpack_/vendor.bundle.js
› http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js (/Users/auchenberg/development/angular-demo/node_modules/jasmine-core/lib/jasmine-core/jasmine.js)
› http://localhost:9876/base/node_modules/karma-jasmine-html-reporter/src/lib/adapter.js (/Users/auchenberg/development/angular-demo/node_modules/karma-jasmine-html-reporter/src/lib/adapter.js)
› http://localhost:9876/base/node_modules/karma-jasmine-html-reporter/src/lib/html.jasmine.reporter.js (/Users/auchenberg/development/angular-demo/node_modules/karma-jasmine-html-reporter/src/lib/html.jasmine.reporter.js)
› http://localhost:9876/base/node_modules/karma-jasmine-html-reporter/src/lib/html.jasmine.reporter.js (/Users/auchenberg/development/angular-demo/node_modules/karma-jasmine-html-reporter/src/lib/html.jasmine.reporter.js)
› http://localhost:9876/base/node_modules/karma-jasmine/lib/adapter.js (/Users/auchenberg/development/angular-demo/node_modules/karma-jasmine/lib/adapter.js)
› http://localhost:9876/base/node_modules/karma-jasmine/lib/boot.js (/Users/auchenberg/development/angular-demo/node_modules/karma-jasmine/lib/boot.js)
› http://localhost:9876/context.js
› http://localhost:9876/debug.html
› http://localhost:9876/debug.js
› ng:///DynamicTestModule/AppComponent.ngfactory.js
    - ng:///DynamicTestModule/AppComponent.ngfactory.js (/Users/auchenberg/development/angular-demo/DynamicTestModule/ng:/DynamicTestModule/AppComponent.ngfactory.js)
    - ng:///DynamicTestModule/AppComponent.html (/Users/auchenberg/development/angular-demo/DynamicTestModule/ng:/DynamicTestModule/AppComponent.html)
› ng:///DynamicTestModule/AppComponent_Host.ngfactory.js
    - ng:///DynamicTestModule/AppComponent_Host.ngfactory.js (/Users/auchenberg/development/angular-demo/DynamicTestModule/ng:/DynamicTestModule/AppComponent_Host.ngfactory.js)
    - ng:///DynamicTestModule/AppComponent_Host.html (/Users/auchenberg/development/angular-demo/DynamicTestModule/ng:/DynamicTestModule/AppComponent_Host.html)
› ng:///DynamicTestModule/module.ngfactory.js
    - ng:///DynamicTestModule/module.ngfactory.js (/Users/auchenberg/development/angular-demo/DynamicTestModule/ng:/DynamicTestModule/module.ngfactory.js)

Looks like there's some magic bundeling going on now in ng:///DynamicTestModule/AppComponent.ngfactory.js, as the file names are vastly different then source.

@auchenberg
Copy link
Contributor

Downgrading to angular-cli 1.1.1 resolves the issue. Seems to validate this reported issue in angular-cli. angular/angular-cli#6824

@roblourens
Copy link
Member

That issue sounds very relevant :D

@weinand
Copy link
Contributor Author

weinand commented Jun 29, 2017

@auchenberg thanks for investigating this and finding angular/angular-cli#6824.
I will update the recipe to make users aware of that problem for angular-cli versions > 1.1.1.
We will try to fix this in July.

@weinand weinand added this to the July 2017 milestone Jun 29, 2017
@daBishMan
Copy link

first off thank you so much for your work, and your time.

Can you please add steps to debug e2e tests, using protractor and the CLI

@tonysneed
Copy link

tonysneed commented Jun 30, 2017

@weinand I'm working on PR #11 for the recipe for setting the exact version of Angular CLI to 1.1.1.

@weinand
Copy link
Contributor Author

weinand commented Jun 30, 2017

@tonysneed thanks a lot

@daBishMan
Copy link

@tonysneed @weinand just for learning purpose, whey running npm start vs. ng start ? if you have the same version of the CLI locally and globally it should be OK to go with ng start ?

@tonysneed
Copy link

@daBishMan So the issue arises when you update the global CLI package. If you run ng serve then you are using the global package, which would then be a greater version that the local package. If there is an issue with the newer version of the global package, such as broken source maps, then you may not be able to debug.

So it's much better to use npm start because you are guaranteed to use the local version which is set exactly (no caret or tilde) in package.json.

Also you can pass args to the npm command. For example to open the browser:

npm start -- -o

@daBishMan
Copy link

@tonysneed thank you :)

@tonysneed
Copy link

@weinand @daBishMan Happy to help! 😄

@daBishMan
Copy link

daBishMan commented Jul 22, 2017

@tonysneed thank you so much for your help with this.

When I try to debug e2e tests I get the error below. Yes, the breakpoint gets hit in VS Code, but the test fails. Anyone else experiencing this?

You can check it out via this repo https://github.com/daBishMan/biz-app

  1. biz-app App should display welcome message
  • Failed: Error while waiting for Protractor to sync with the page: "window.angular is undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
    Executed 1 of 1 spec (1 FAILED) in 9 secs.

@auchenberg
Copy link
Contributor

@daBishMan I just clone your repo and ran Launch ng e2e from VS Code 1.14.1 and things work as expected after I first ran ng e2e from the Terminal (installed webdriver dependencies)

@angular/cli: 1.2.3
node: 7.9.0
os: darwin x64
@angular/animations: 4.3.1
@angular/common: 4.3.1
@angular/compiler: 4.3.1
@angular/core: 4.3.1
@angular/forms: 4.3.1
@angular/http: 4.3.1
@angular/platform-browser: 4.3.1
@angular/platform-browser-dynamic: 4.3.1
@angular/router: 4.3.1
@angular/cli: 1.2.3
@angular/compiler-cli: 4.3.1
@angular/language-service: 4.3.1

screen shot 2017-07-24 at 3 43 30 pm

@daBishMan
Copy link

daBishMan commented Jul 25, 2017

@auchenberg thanks again very much for your help yes, it does work now; really appreciate your time :)

@Looted
Copy link

Looted commented Aug 28, 2017

I have a related issue so I'll just ask here instead of creating another issue. The debugging works for me in such way, that when I'm stepping forward, nothing happens in the browser. Only after I step out of the it blocks, the commands actually run in the browser. Is this the desired behavior? When running e2e tests in Ruby I could step forward and see what the browser is actually doing each step (so I could inspect the DOM state etc.)

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug
Projects
None yet
Development

No branches or pull requests

6 participants