-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use TestAdapter to ensure render errors are thrown (#129)
Uses a customized test adapter for some tests that will rethrow errors that occur during the render cycle. This fixes a few tests that were false-negativing. Notes on the change to Ember are in emberjs/ember.js#14898 Fixes #128
- Loading branch information
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Ember from 'ember'; | ||
import { QUnitAdapter } from 'ember-qunit'; | ||
|
||
/** | ||
* Creates a TestAdapter that will throw when an exception is encountered. | ||
* Before Ember 2.11, errors that occur in tests during `this.render` were thrown | ||
* and catchable (and therefore testable using `assert.throws`), but | ||
* in https://github.com/emberjs/ember.js/pull/14898 this changed and we need | ||
* to override the Test Adapter's exception handler to rethrow the error. | ||
* | ||
* This file and any references can be removed if the Ember Test Adapter's | ||
* error-handling behavior changes in the future. | ||
*/ | ||
|
||
const ThrowingAdapter = QUnitAdapter.extend({ | ||
exception(error) { | ||
// rethrow error | ||
throw error; | ||
} | ||
}); | ||
|
||
export function setup(context) { | ||
let origTestAdapter = Ember.Test.adapter; | ||
context.__originalTestAdapter = origTestAdapter; | ||
|
||
Ember.run(() => { Ember.Test.adapter = ThrowingAdapter.create(); }); | ||
} | ||
|
||
export function teardown(context) { | ||
if (context.__originalTestAdapter) { | ||
Ember.run(() => { | ||
context.__originalTestAdapter.destroy(); | ||
delete context.__originalTestAdapter; | ||
|
||
Ember.Test.adapter = QUnitAdapter.create(); | ||
}); | ||
} | ||
} |
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