I am using custom typings for my angular project to avoid rework in client side for strict typings. However, it is not working while running unit tests.
I am not sure, how to bring this namespace while running unit tests. Below is the code we have
Component
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
title = 'app';
public employees: Company.Core.DTO.IEmployee[];
}
SPEC
import { NO_ERRORS_SCHEMA } from "@angular/core";
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('SearchComponent',
() => {
let fixture: ComponentFixture<AppComponent>;
let component: AppComponent;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [AppComponent],
schemas: [NO_ERRORS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AppComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Typings in file (app/typings/Company.typings.ts) autogenerated by TypeLite
declare module Company.Core.DTO {
interface IEmployee {
Number: number;
Age: number;
Name: string;
}
}
Error while executing unit test
error TS2503: Cannot find namespace Company
This happens only during unit testing compilation. While running application, we are not getting this error.
Tried this Angular2 Cannot find namespace 'google' but no luck
NPM packages
Angular : 8.2.12
jasmine-core : ~3.5.0
karma: ^4.4.1
karma-jasmine : ~2.0.1
typescript: 3.5.3