Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ember.onerror error while running tests #5

Closed
Windvis opened this issue Dec 5, 2019 · 2 comments
Closed

Ember.onerror error while running tests #5

Windvis opened this issue Dec 5, 2019 · 2 comments

Comments

@Windvis
Copy link

Windvis commented Dec 5, 2019

When I run the tests locally I see the following error:

not ok 17 Chrome 78.0 - [2 ms] - ember-qunit: Ember.onerror validation: Ember.onerror is functioning properly
    ---
        actual: >
            false
        expected: >
            true
        stack: >
                at Object.<anonymous> (http://localhost:7357/assets/test-support.js:10953:16)
                at runTest (http://localhost:7357/assets/test-support.js:4394:30)
                at Test.run (http://localhost:7357/assets/test-support.js:4380:6)
                at http://localhost:7357/assets/test-support.js:4601:12
                at advanceTaskQueue (http://localhost:7357/assets/test-support.js:3993:6)
                at advance (http://localhost:7357/assets/test-support.js:3974:4)
        message: >
            Ember.onerror handler with invalid testing behavior detected. An Ember.onerror handler _must_ rethrow exceptions when `Ember.testing` is `true` or the test suite is unreliable. See https://git.io/vbine for more details.
        negative: >
            false
        browser log: |
            ERROR: [object Object] [object Object]
    ...

The link in the error message leads to this page and provides more information about how to fix it.

@Mifrill
Copy link

Mifrill commented Nov 11, 2020

Hey, @KamiKillertO can you do some updates on this, please? I have an intermittent test freeze with the same issue.
Hey, @Windvis, did you resolve it?

@Mifrill
Copy link

Mifrill commented Jan 22, 2021

Hey, @Windvis I've resolved it by restore Ember.onerror mock:

import Ember from 'ember';

const { Test, Logger } = Ember;

export default function mockAdapterErrors(hooks = self) {
  hooks.beforeEach(function() {
    interceptExceptions.call(this);
  });

  hooks.afterEach(function() {
    restoreExceptions.call(this);
  });
}

export function interceptExceptions() {
  this.originalLoggerError = Logger.error;
  this.originalTestAdapterException = Test.adapter.exception;
  this.originalOnError = Ember.onerror;
  Logger.error = () => {};
  Test.adapter.exception = () => {};
  Ember.onerror = () => {};
}

export function restoreExceptions() {
  Logger.error = this.originalLoggerError;
  Test.adapter.exception = this.originalTestAdapterException;
  Ember.onerror = this.originalOnError;
}

@Windvis Windvis closed this as completed Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants