question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to test `Ember.onError` after upgrading

See original GitHub issue

I’m in the process of upgrading to ember 2.10. One of the packages upgraded was ember-cli-qunit which in turn upgrades ember-qunit to 2.0. One problem that I’m faced with is that I am now unable to acceptance test my application’s error handling (which is oddly complex and important to test).

The problem is that ember-qunit now providers their own test adapter (See: ember-qunit#234). And the test-loader bundled with ember-cli-qunit just imports it, instanitaties it and set’s it as global (See: ember-cli-qunit#134).

Before this upgrade I would just do the following:

let useEmberOnError = false;
Ember.Test.QUnitAdapter.reopen({
  exception(error) {
    if (useEmberOnError) {
      Ember.onerror(error);
      return;
    }

    this._super(...arguments);
  }
});

But now I’m no longer able to monkey patch this. I think I could probably replace the Ember.Test.adapter instance with my own, but this feels brittle. I’m curious what you guys think the “right solution” might be to acceptance test application error handling.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rwjbluecommented, Dec 1, 2016

I think the best way to do this is:

// tests/qunit-adapter.js
import { QUnitAdapter } from 'ember-qunit';

let useEmberOnError = false;
export default QUnitAdapter.extend({
  exception(error) {
    if (useEmberOnError) {
      Ember.onerror(error);
      return;
    }

    this._super(...arguments);
  }
})
// tests/test-helper.js

/* existing contents */

import QUnitAdapter from './qunit-adapter';
Ember.Test.adapter = QUnitAdapter.create();
0reactions
thisFunctioncommented, Jun 16, 2017

start({setupTestAdapter: false});

Thanks, @kbullaughey! This worked for me when testing backend error responses.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrading Ember - Issues with Tests - Questions
So I took on the task of upgrading our Ember app from 2.16 to 3.26. The application runs fine locally. Got through the...
Read more >
How to avoid Ember tests failing if endpoint returns 404?
When running my tests, some endpoints returns an 404 (which is expected), but my test fails with the following log:
Read more >
Making error states easy to test | Mirage tips and tricks
In this video I want to show you how to test your application when it gets into an error state as a result...
Read more >
@ember/test-helpers | Yarn - Package Manager
A test-framework-agnostic set of helpers for testing Ember.js applications. Compatibility. Ember 3.8 or above; Ember CLI 3.8 or above; Node.js 10 or above ......
Read more >
Upgrading to Ember 2.x - pablobm
This is fixed by installing the Bower package. Pay special attention to the fact that the version comes after a '#', not an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found