小编chi*_*owl的帖子

Knockout应用程序可以使用Protractor进行测试吗?

我正在使用Knockout的网页.我看到这篇关于在非Angular页面上使用Protractor的帖子后设置了Protractor ,但似乎Protractor不能"看到"任何属于KO组件的元素.

describe('a simple test', function () {
  it('works', function () {
    browser.ignoreSynchronization = true;
    browser.get('profile');

    expect(browser.getTitle()).toEqual('Title');  // this passes (outside KO)

    expect(element(by.id('ko-component')).getText()).toEqual('Hello World!'); // this fails (inside KO)
  });
});
Run Code Online (Sandbox Code Playgroud)

第二个断言导致此错误,即使该元素肯定在HTML中.

Message:
 NoSuchElementError: No element found using locator: By.id("ko-component")
Run Code Online (Sandbox Code Playgroud)

如果我不能使用Protractor,那么欢迎提出其他e2e测试框架的建议.

javascript knockout.js protractor e2e-testing

6
推荐指数
1
解决办法
642
查看次数

Application Insights 不会跟踪 Angular 应用中未处理的浏览器异常

我遇到了 Microsoft Application Insights SDK for JavaScript 的问题,该问题前一段时间已关闭/已修复:https : //github.com/Microsoft/ApplicationInsights-JS/issues/282

我使用 Angular CLI 创建了一个全新的 Angular 应用程序。然后我按照这篇文章进行了这些更改。

添加了监控服务:

import {Injectable} from '@angular/core';
import {AppInsights} from 'applicationinsights-js';

@Injectable()
export class MonitoringService {
  private config: Microsoft.ApplicationInsights.IConfig = {
    instrumentationKey: 'KEY_GOES_HERE',
    enableDebug: true,
    verboseLogging: true
  };

  constructor() {
    if (!AppInsights.config) {
      AppInsights.downloadAndSetup(this.config);
    }
  }

  logPageView(name?: string, url?: string, properties?: any, measurements?: any, duration?: number) {
    AppInsights.trackPageView(name, url, properties, measurements, duration);
  }

  logEvent(name: string, properties?: any, measurements?: any) {
    AppInsights.trackEvent(name, properties, measurements); …
Run Code Online (Sandbox Code Playgroud)

javascript azure azure-application-insights angular

6
推荐指数
1
解决办法
3222
查看次数