when I run ng test
I get this error (I use standard setup with Karma
) when I try to test component:
XMLHttpRequest cannot load ng:///DynamicTestModule/FullModalHeaderComponent.ngfactory.js. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
How can I address this issue?
Code:
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FullModalHeaderComponent } from './full-modal-header.component';
describe('FullModalHeaderComponent', () => {
let component: FullModalHeaderComponent;
let fixture: ComponentFixture<FullModalHeaderComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [FullModalHeaderComponent]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(FullModalHeaderComponent);
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});
and
import { Component, Input } from '@angular/core';
import { ProcessingCenter, Publication } from '../../publications/model';
@Component({
selector: 'gom-full-modal-header',
templateUrl: './full-modal-header.component.html'
})
export class FullModalHeaderComponent {
@Input('processingCenter') processingCenter: ProcessingCenter;
@Input('publication') publication: Publication;
@Input('title') title: string;
}
Also, when I run tests with ng test --sourcemaps=false
issue goes away.
ng test --sourcemaps=false
and update the post ? This issue is most probably a fake one since there is no way this is a CORS issue. Also, can you post your HTML template code ? I think this is coming from here--sourcemaps=false
anymore. exemple :{{entity.count}}
==>{{entity?.count}}