-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Hi,
I am trying to run unit tests on an angular project with polymer.
I used this repository for checking the same. With minimal changes I could see Jasmine started running the unit tests after adding CUSTOM_ELEMENTS_SCHEMA & importing RouterTestingModule.
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { RouterTestingModule } from '@angular/router/testing';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA} from '@angular/core';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
imports: [RouterTestingModule],
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.overrideComponent(AppComponent, {
set: {
template: ''
}}).createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
After this change I started seeing the error:
Unit test: AppComponent should create the app
[object ErrorEvent] thrown
[object ErrorEvent] thrown
[object ErrorEvent] thrown
[object ErrorEvent] thrown
[object ErrorEvent] thrown
[object ErrorEvent] thrown
[object ErrorEvent] thrown
Error: Expected undefined to equal 'app'.
at stack (http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?da99c5b057693d025fad3d7685e1590600ca376d:2176:17)
at buildExpectationResult (http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?da99c5b057693d025fad3d7685e1590600ca376d:2146:14)
at Spec.expectationResultFactory (http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?da99c5b057693d025fad3d7685e1590600ca376d:766:18)
at Spec.addExpectationResult (http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?da99c5b057693d025fad3d7685e1590600ca376d:444:34)
at Expectation.addExpectationResult (http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?da99c5b057693d025fad3d7685e1590600ca376d:710:21)
at Expectation.toEqual (http://localhost:9876/base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?da99c5b057693d025fad3d7685e1590600ca376d:2099:12)
at Object.eval (webpack:///D:/PLM_TE/17._Angular2/NgPolyPotractor/angular-polymer-starter-kit-master/src/app/app.component.spec.ts?:33:27)
at ZoneDelegate.invoke (webpack:///D:/PLM_TE/17._Angular2/NgPolyPotractor/angular-polymer-starter-kit-master/node_modules/zone.js/dist/zone.js?:388:26)
at AsyncTestZoneSpec.onInvoke (webpack:///D:/PLM_TE/17._Angular2/NgPolyPotractor/angular-polymer-starter-kit-master/node_modules/zone.js/dist/async-test.js?:49:39)
at ProxyZoneSpec.onInvoke (webpack:///D:/PLM_TE/17._Angular2/NgPolyPotractor/angular-polymer-starter-kit-master/node_modules/zone.js/dist/proxy.js?:76:39)
It looks like Polymer elements are null and unable to initialize the component. But I couldn't get any more information. Any idea what I am missing that Jasmine expects.
I tried disabling source_maps as mentioned here, angular/angular-cli#7296 but that also didn't work. [ng test --sm=false]
Regards
Basanth