Created
January 4, 2016 11:15
-
-
Save matthewdenobrega/3042444445dd66fa9679 to your computer and use it in GitHub Desktop.
Catch handler to force unit tests to fail on exception
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {ComponentFixture, describe, expect, inject, it, TestComponentBuilder} from 'angular2/testing' | |
import {Component, View} from 'angular2/src/core/metadata' | |
@Component({ selector: 'basic-component' }) | |
@View({ template: '<div></div>' }) | |
class BasicComponent { } | |
// Set up the browser adapter | |
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter' | |
BrowserDomAdapter.makeCurrent() | |
describe('BasicComponent', () => { | |
it('should create a new component', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { | |
tcb.createAsync(BasicComponent).then((fixture: ComponentFixture) => { | |
expect(fixture.debugElement).not.toBe(null) | |
throw ('exception') | |
expect(false).toBe(true) | |
}).catch(() => { | |
expect(false).toBe(true) | |
}) | |
})) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment