繁体   English   中英

调试从 Angular CLI 的 `ng e2e` 开始的量角器测试

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

如何使用与ng e2e运行的 Angular 6+ 调试量角器测试。

我在e2e/protractor.conf.js文件中设置了debug: true 在测试中调用browser.pause()时出现错误和提示,我应该使用debugger; 关键词。 但是 Usign 没有效果。

示例代码:

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

这是我得到的警告:

***********************************************************
* 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)

我试图按照提供的 ling 中的说明( https://github.com/angular/protractor/blob/master/docs/debugging.md ),但这并不是真正的帮助。

有人有关于如何使用 Angular-CLI 设置 e2e 测试调试的教程吗?

不确定您是否找到了解决问题的方法。 但我在这里找到了一些帮助。

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

对于 Node v8+:-

  • 在你的protractor.conf.js设置SELENIUM_PROMISE_MANAGER: false
  • 将您的tsconfig.e2e.jsontarget更新为"target": "es2017"
  • 使用异步/等待 例如-

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

它解决了我的问题。 希望对你也有帮助。 如果您也找到其他解决方案,请分享。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM