Tarator
Tarator

Reputation: 1524

Debugging protractor tests which are started with Angular CLI's `ng e2e`

How can a protractor test be debugged using Angular 6+ running with ng e2e.

I set debug: true in the e2e/protractor.conf.js file. When calling browser.pause() in the test I get an error and the hint, that I should use the debugger; keyword. Usign has no effect though.

Example code:

it('the user-menu should be present', () => {
  page.navigateTo();
  browser.pause();
  //debugger;
  let elem = page.getUserIconMenuButton();
  expect(elem.isPresent()).toBeTruthy();
});

This is the warning I get:

***********************************************************
* WARNING: _debugger module not available on Node.js 8    *
* and higher.                                             *
*                                                         *
* Use 'debugger' keyword instead:                       *
* https://github.com/angular/protractor/blob/master/docs/debugging.md                               
***********************************************************
C:\...\node_modules\protractor\built\debugger\debuggerCommons.js:14
  throw e;
  ^

Error: Cannot find module '_debugger'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\...\node_modules\protractor\built\debugger\debuggerCommons.js:3:18)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

I tried to follow the instructions in the ling provided ( https://github.com/angular/protractor/blob/master/docs/debugging.md ) but this isn't really a help.

Has anybody a Tutorial on how to setup debugging of e2e tests using Angular-CLI?

Upvotes: 2

Views: 1584

Answers (1)

Yashwardhan Pauranik
Yashwardhan Pauranik

Reputation: 5556

Not sure if you had found any solution to the problem. But I found some help here.

https://github.com/angular/protractor/issues/4307#issuecomment-386112285

For Node v8+:-

  • Set SELENIUM_PROMISE_MANAGER: false in your protractor.conf.js
  • Update your tsconfig.e2e.json's target as "target": "es2017"
  • Use async/await . For eg-

     it('should greet the named user', async function() {
       await browser.get('http://www.angularjs.org');
       await element(by.model('yourName')).sendKeys('Julie');
     });```
    

It fixed my problem. Hope it helps you too. Please share if you find some other solution too.

Upvotes: 3

Related Questions