预计在“proxyzone”中运行,但在角度项目中未找到

问题描述 投票:0回答:1

当创建一个新项目时,ng 测试工作正常,之后我添加了 Primeng 和 Bootstrap 库,现在我收到错误“预计在‘proxyzone’中运行,但未找到”我没有使用“fakeAsync”。代码已附上。

import 'zone.js/dist/zone-testing'
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';

describe('AppComponent', () => {
  beforeEach(async () => {
    await TestBed.configureTestingModule({
      imports: [
        RouterTestingModule
      ],
      declarations: [
        AppComponent
      ],
    }).compileComponents();
  });

  it('should create the app', () => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.componentInstance;
    expect(app).toBeTruthy();
  });

  it(should have as title 'UI-design', () => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.componentInstance;
    expect(app.title).toEqual('UI-design');
  });

  it('should render title', () => {
    const fixture = TestBed.createComponent(AppComponent);
    fixture.detectChanges();
    const compiled = fixture.nativeElement as HTMLElement;
    expect(compiled.querySelector('.content span')?.textContent).toContain('UI-design app is running!');
  });
});

angular karma-jasmine angular-test
1个回答
0
投票

就我而言,通过在 tsconfig 中将

compilerOptions.target
设置为
es2016
解决了错误。

© www.soinside.com 2019 - 2024. All rights reserved.