-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
Async Example for acceptance-test #163
Comments
See following gist: |
Our team member was able to workaround the issue by using:
instead of
Does ember-qunit fail before the catch for rejected promises? |
It seems ember-qunit fails whenever an error is not handled within the first
|
@olivierlesnicki You can try to rewrite the original /* jshint ignore:start */
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'payment-widget/tests/helpers/start-app';
let adapterException;
module('Acceptance | amount | server errors', {
beforeEach() {
this.application = startApp();
// Ignore promise rejection.
// Original exception will fail test on promise rejection.
adapterException = Ember.Test.adapter.exception;
Ember.Test.adapter.exception = () => null;
},
afterEach() {
Ember.Test.adapter.exception = adapterException;
Ember.run(this.application, 'destroy');
}
});
test('visiting /:receiverId with invalid receiverId', async (assert) => {
server.get('/payment-receivers/:id', null, 404);
await visit(`/123`);
assert.equal(currentRouteName(), 'not-found', 'it redirects to not-found route on 404 status');
server.get('/payment-receivers/:id', null, 500);
await visit(`/123`);
assert.equal(currentRouteName(), 'error', 'it redirects to error route on 500 status');
}); If you'd like to hide console log errors you could also rewrite beforeEach() {
this.application = startApp();
adapterException = Ember.Test.adapter.exception;
emberLoggerError = Ember.Logger.error;
Ember.Test.adapter.exception = () => null;
Ember.Logger.error = () => null;
},
afterEach() {
Ember.Test.adapter.exception = adapterException;
Ember.Logger.error = emberLoggerError;
Ember.run(this.application, 'destroy');
} |
I am also experiencing the same trouble when trying to test "error" states conditions. The weird part is that my tests are only failing on [email protected] although the adapter has not changed since 1.13.x (or before) as you can see here. I´m still trying to figure out what is going on, although temporary replacing the |
closing this issue, as it should be resolved by the new testing APIs |
On the README.md it is stated that:
If an error is thrown in your promise or a promise within test becomes rejected, ember-qunit will fail the test. To assert that a promise should be rejected, you can "catch" the error and assert that you got there:
While this works well for unit tests, I'm unable to find an equivalent workaround for acceptance test. I'd like to test scenarios in which my server calls fail (400, 500, etc..). But the error is always thrown and ember-qunit fail.
The text was updated successfully, but these errors were encountered: