Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { run } from '@ember/runloop';
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;
run(() => { Ember.Test.adapter = ThrowingAdapter.create(); });
}
export function teardown(context) {
if (context.__originalTestAdapter) {
run(() => {
import { QUnitAdapter } from 'ember-qunit';
import Ember from 'ember';
const useEmberOnError = true;
export default QUnitAdapter.extend({
exception(error) {
if (useEmberOnError) {
Ember.onerror(error);
return;
}
this._super(...arguments);
}
});
import Ember from 'ember';
import QUnit from 'qunit';
import { QUnitAdapter } from 'ember-qunit';
import { checkMatcher } from '../-private/utils';
let TestAdapter = QUnitAdapter.extend({
exception(error) {
this.lastError = error;
}
});
let noop = () => {};
export default function() {
let isProductionBuild = (function() {
try {
Ember.assert('fails in debug builds');
} catch(e) {
return false;
}
return true;