В моем проекте я включил только файл спецификации PathNotFoundComponent, все остальные файлы спецификаций закомментированы, и я получаю вышеуказанную ошибку.
Мой файл компонента,
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-path-not-found',
templateUrl: './path-not-found.component.html',
styleUrls: ['./path-not-found.component.scss']
})
export class PathNotFoundComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
Мой файл спецификации компонента,
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PathNotFoundComponent } from './path-not-found.component';
describe('PathNotFoundComponentComponent', () => {
let component: PathNotFoundComponent;
let fixture: ComponentFixture<PathNotFoundComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PathNotFoundComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PathNotFoundComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Но эти тестовые случаи работают в следующих случаях.
Если я изменяю beforeEach на beforeAll в файле спецификации компонента.
Или
В файле test.ts измените файл require.context ('./', true, /.spec.ts$/) на require.context ('./', true, /path-not-found.component.spec.ts$/)
Пожалуйста, помогите мне найти решение?