Here is the code for the component I am testing:
import { Component, Input, OnInit } from '@angular/core';
import { ContentfulService } from '../../services/index';
import * as showdown from 'showdown';
@Component({
moduleId: module.id,
selector: 'dt-contact-us',
templateUrl: 'contact-us.html'
})
export class ContactUsComponent implements OnInit {
public title: string;
public text: string;
public contactFormTitle: string;
public contactFormSubtitle: string;
public address: string;
@Input() parentData: any;
constructor (private _contentService: ContentfulService) {}
ngOnInit() {
if (this.parentData != null) {
let converter = new showdown.Converter();
// retreive content
let contactUs = this._contentService.getLinkedEntry(this.parentData, this.parentData.items[0].fields.contactUs.sys.id);
// set content
this.title = contactUs.fields.title;
this.text = converter.makeHtml(contactUs.fields.text);
this.contactFormTitle = contactUs.fields.contactFormTitle;
this.contactFormSubtitle = contactUs.fields.contactFormSubtitle;
this.address = converter.makeHtml(contactUs.fields.address);
}
}
}
Pretty simple, and here is the incomplete test I am trying to just get to run properly without failing:
import { Observable } from 'rxjs/Rx';
import { TestBed, async } from '@angular/core/testing';
import { ContactUsComponent } from './index';
describe("Contact Component", () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
ContactUsComponent
]
});
});
it("can initialize component", async(() => {
TestBed.compileComponents().then(() => {
const fixture = TestBed.createComponent(ContactUsComponent);
});
}));
});
When I run this I get the following error output from phantomJS:
PhantomJS 2.1.1 (Windows 8 0.0.0) Contact Component can initialize header FAILED invokeTask@node_modules/http://ift.tt/2nNJeZc onInvokeTask@node_modules/http://ift.tt/2nWpwYg invokeTask@node_modules/http://ift.tt/2nNArGI runTask@node_modules/http://ift.tt/2nWxaBV drainMicroTaskQueue@node_modules/http://ift.tt/2nNHVJJ g@node_modules/core-js/client/shim.min.js:8:19058 node_modules/core-js/client/shim.min.js:8:19180 k@node_modules/core-js/client/shim.min.js:8:14294 resolvePromise@node_modules/http://ift.tt/2nWrs33 node_modules/http://ift.tt/2nsTJAe PhantomJS 2.1.1 (Windows 8 0.0.0): Executed 16 of 16 (1 FAILED) (0.977 secs / 0.928 secs) [17:11:47] Remapping coverage to TypeScript format... [17:11:47] Test Done with exit code: 1 [17:11:47] 'unit-test' errored after 13 s [17:11:47] Error: 1 at formatError (C:\Users\jonathan.lane\Documents\dt-front-end\node_modules\gulp\bin\gulp.js:169:10) at Gulp. (C:\Users\jonathan.lane\Documents\dt-front-end\node_modules\gulp\bin\gulp.js:195:15) at emitOne (events.js:101:20) at Gulp.emit (events.js:188:7) at Gulp.Orchestrator._emitTaskDone (C:\Users\jonathan.lane\Documents\dt-front-end\node_modules\orchestrator\index.js:264:8) at C:\Users\jonathan.lane\Documents\dt-front-end\node_modules\orchestrator\index.js:275:23 at finish (C:\Users\jonathan.lane\Documents\dt-front-end\node_modules\orchestrator\lib\runTask.js:21:8) at cb (C:\Users\jonathan.lane\Documents\dt-front-end\node_modules\orchestrator\lib\runTask.js:29:3) at DestroyableTransform. (C:\Users\jonathan.lane\Documents\dt-front-end\config\gulp\tasks\test.js:67:13) at emitNone (events.js:91:20) at DestroyableTransform.emit (events.js:185:7) at finishMaybe (C:\Users\jonathan.lane\Documents\dt-front-end\node_modules\remap-istanbul\node_modules\readable-stream\lib_stream_writable.js:475:14) at afterWrite (C:\Users\jonathan.lane\Documents\dt-front-end\node_modules\remap-istanbul\node_modules\readable-stream\lib_stream_writable.js:361:3) at onwrite (C:\Users\jonathan.lane\Documents\dt-front-end\node_modules\remap-istanbul\node_modules\readable-stream\lib_stream_writable.js:352:9) at WritableState.onwrite (C:\Users\jonathan.lane\Documents\dt-front-end\node_modules\remap-istanbul\node_modules\readable-stream\lib_stream_writable.js:123:5) at afterTransform (C:\Users\jonathan.lane\Documents\dt-front-end\node_modules\remap-istanbul\node_modules\readable-stream\lib_stream_transform.js:81:3) [17:11:47] Remapping done! View the result in report/remap/html-report npm ERR! Test failed. See above for more details.
Anyone have any ideas why this is failing even though basically nothing is being done in the test?
Aucun commentaire:
Enregistrer un commentaire