1

私は最近、自分のイオン プロジェクトを 4 から 5 に更新することに決めました。その間に、Angular 8 から 9 に更新することを考えました。

単体テストを実行しようとするまで、すべてがうまくいき、アプリは期待どおりに動作します。私はこのエラーに襲われ、その理由がわかりません。ルーターに関係していると思われますが、それを確認することさえできません。

Error: This constructor was not compatible with Dependency Injection.
Error: This constructor was not compatible with Dependency Injection.
    at Module.ɵɵinvalidFactory (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js:14150:1)
    at Object.Router_Factory [as factory] (http://localhost:9876/_karma_webpack_/node_modules/@angular/router/__ivy_ngcc__/fesm5/router.js:4404:67)
    at R3Injector.push../node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js.R3Injector.hydrate (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js:11425:1)
    at R3Injector.push../node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js.R3Injector.get (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js:11247:1)
    at injectInjectorOnly (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js:787:1)
    at Module.ɵɵinject (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js:792:1)
    at Function.NavController_Factory [as ɵfac] (http://localhost:9876/_karma_webpack_/node_modules/@ionic/angular/__ivy_ngcc__/fesm5/ionic-angular.js:798:205)
    at Object.factory (http://localhost:9876/_karma_webpack_/node_modules/@ionic/angular/__ivy_ngcc__/fesm5/ionic-angular.js:799:96)
    at R3Injector.push../node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js.R3Injector.hydrate (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js:11425:1)
    at R3Injector.push../node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js.R3Injector.get (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm5/core.

アイデアや他の誰かがこれに出くわしますか?

編集

失敗したテストの 1 つが次のようになります。

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';

import { ZoneInstructionsComponent } from './zone-instructions.component';
import { LocationStrategy, Location, PathLocationStrategy, APP_BASE_HREF } from '@angular/common';
import { UrlSerializer, Router, RouterModule } from '@angular/router';

describe('ZoneInstructionsComponent', () => {
  let component: ZoneInstructionsComponent;
  let fixture: ComponentFixture<ZoneInstructionsComponent>;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ ZoneInstructionsComponent ],
      imports: [ IonicModule.forRoot() ],
      providers: [
        Location,
        { provide: LocationStrategy, useClass: PathLocationStrategy },
        { provide: APP_BASE_HREF, useValue: '/page' },
        UrlSerializer,
        { provide: Router, userClass: RouterModule },
      ]
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(ZoneInstructionsComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});

かなり基本的で、実際には何もテストしていません

編集2

これがコンポーネントコードです。何もする必要はありません

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'stm-zone-instructions',
  templateUrl: './zone-instructions.component.html',
  styleUrls: [
    '../installation-wizard.page.scss',
    './zone-instructions.component.scss'
  ]
})
export class ZoneInstructionsComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

}

4

1 に答える 1