2017-01-13 17 views
9

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ố đó.

+3

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

Trả lời

5

Tôi đã tìm ra vấn đề là gì. Tôi đã thêm một console.log() vào tệp errors.js nơi đã báo cáo lỗi và tôi có thêm thông tin về ngữ cảnh. Trong thực tế, tôi đã sử dụng một bài sơ khai cho những bài kiểm tra mà bỏ lỡ một EventEmitter cụ thể. Điều này kích hoạt một lỗi nhưng có vẻ như là một lỗi trong báo cáo lỗi ngăn cản nghiệp từ xuất ra đúng thông điệp.

console.log() là bạn của bạn

Các vấn đề liên quan