Having issues while attempting to write a basic test in Angular 2, specifically with an error related to environment.ts
:
ERROR in ./web/environments/environment.ts Module build failed: Error: web\environments\environment.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
app.component.ts
import { Component} from '@angular/core';
import { environment } from '../environments/environment';
@Component({
selector: 'web-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
title = 'Test App';
constructor() {
console.log(environment);
}
}
app.component.spec.ts
import { AppComponent } from './app.component';
describe('AppComponent', () => {
it(`should 1+1`, () => {
expect(1 + 1).toEqual(2); //Success
});
it('should have component ', () => {
const component = new AppComponent(); //Throws error
// expect(component).toBeTruthy();
});
});
Any ideas on how to resolve this issue?