tôi nâng cấp một dự án kiễu góc 2.1.0 đến 2.3.1 sáng nay, và kể từ đó 5 của 86 thử nghiệm của tôi thất bại với các lỗi sau:Đã cố gắng để gán cho readonly sở hữu kể từ nâng cấp góc để 2.3.1
Failed: Attempted to assign to readonly property. [email protected]:///~/@angular/core/src/facade/errors.js:43:33 <- src/test.ts:12465:52
đây là bài kiểm tra đơn giản nhất đó là thất bại:
/* tslint:disable:no-unused-variable */
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {ProfileComponent} from './profile.component';
import {TranslateModule, TranslateService} from 'ng2-translate';
import {FormsModule} from '@angular/forms';
import {ProfileService} from '../profile.service';
import {ProfileServiceStub} from '../../../testing/profile-service-stub';
import {TranslateServiceStub} from '../../../testing/translate-service-stub';
import {NotificationsServiceStub} from '../../../testing/notifications-service-stub';
import {NotificationsService} from 'angular2-notifications';
describe('ProfileComponent',() => {
let component: ProfileComponent;
let fixture: ComponentFixture<ProfileComponent>;
const profileServiceStub = new ProfileServiceStub(5000);
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ProfileComponent],
imports: [
TranslateModule, FormsModule
],
providers: [
{provide: ProfileService, useValue: profileServiceStub},
{provide: TranslateService, useClass: TranslateServiceStub},
{provide: NotificationsService, useClass: NotificationsServiceStub}
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ProfileComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create',() => {
expect(component).toBeTruthy();
});
});
tôi không thấy bất kỳ sự khác biệt về cấu trúc trong cách kiểm tra được thiết lập, vì vậy tôi đoán nó có cái gì để làm với một cái gì đó tôi đang làm.
Và khi tôi có một cái nhìn tại errors.js, dòng buộc tội trông như thế này:
set: function (message) { this._nativeError.message = message; },
Tôi thực sự không biết làm thế nào để khắc phục sự cố đó.
Tôi gặp vấn đề tương tự. Không có đầu mối làm thế nào để gỡ lỗi này. – Prathap