I have some unit tests (karma + jasmine) written that don’t work with a component that has an ion-content in its template.
Example:
about.ts
@Component({
selector: 'page-about',
templateUrl: 'about.html'
})
export class AboutPage {
public versionnumber: any = 1;
constructor( ) {
}
}
about.html:
<ion-content>something</ion-content>
the spec is very simple:
let fixture: ComponentFixture<AboutPage> = null;
let instance: any = null;
describe('AboutPage', () => {
beforeEach(async(() => TestUtils.beforeEachCompiler([AboutPage]).then(compiled => {
fixture = compiled.fixture;
instance = compiled.instance;
fixture.autoDetectChanges(true)
})))
it('initialises', () => {
expect(fixture).not.toBeNull();
expect(instance).not.toBeNull();
})
})
the output is:
initialises
Chrome 56.0.2924 (Linux 0.0.0)
TypeError: Cannot read property ‘__zone_symbol__addEventListener’ of undefined
at Platform.registerListener (webpack:///~/ionic-angular/platform/platform.js:616:0 ← src/test.ts:1573:30)
at Keyboard.focusOutline (webpack:///~/ionic-angular/platform/keyboard.js:208:0 ← src/test.ts:22904:18)
at new Keyboard (webpack:///~/ionic-angular/platform/keyboard.js:34:0 ← src/test.ts:22730:14)
if I remove ion-content, this error is not thrown. I can change to any other element (either a html5 one, like a div, or an ionic element, like ion-card). But it the template has an ion-content, the test throws this error.
Ionic info:
Cordova CLI: 6.3.1
Ionic Framework Version: 2.2.0
Ionic CLI Version: 2.2.0
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.4
Node Version: v7.6.0
Xcode version: Not installed