Я пишу тестовый блок для компонента. Компонент выглядит следующим образом:
@Component({
selector: ‘test-information’,
templateUrl: ‘./test-information.component.html',
styleUrls: [‘./test-information.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class TestInformationComponent implements OnInit, OnChanges {
@Input() info: Array<any>;
constructor()
{
}
ngOnInit()
{
}
ngOnChanges(changes: SimpleChanges) {
console.log(“value”,changes.info.currentValue);
}
}
Таким образом, в основном этот компонент должен получать массив объектов в качестве входных данных.
Контрольный пример для этого компонента выглядит следующим образом
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Component, ViewChild } from '@angular/core';
import { TestInformationComponent } from './test-information.component';
import { MaterialModule } from '../../modules/material/material.module';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { of } from 'rxjs';
import { By } from '@angular/platform-browser';
fdescribe('TestInformationComponent', () => {
let component: TestInformationComponent;
let fixture: ComponentFixture<TestInformationComponent>;
let fixture1,hostComponent;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TestInformationComponent],
imports: [MaterialModule],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
}));
beforeEach(async(() => {
fixture = TestBed.createComponent(TestInformationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
component.info = [
{
"id": "19",
"name": "test”,
"Score": 36,
"status": “up”
}
];
fixture.detectChanges();
}));
it('should create', () => {
console.log("componetis ",component);
expect(component).toBeTruthy();
});
});
Этот простой пример модульного теста завершается неудачно, я получаю следующую ошибку: Ошибка: Не удается прочитать свойство 'test' из неопределенного
Я не могу понять, где я иду не так.