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

Cannot test failure modes #30

Open
jamesarosen opened this issue Jul 22, 2015 · 3 comments
Open

Cannot test failure modes #30

jamesarosen opened this issue Jul 22, 2015 · 3 comments

Comments

@jamesarosen
Copy link

See emberjs/ember.js#11469

Ember's default Promise.on('error') hook causes the current test to fail if it ever encounters a reject({ anything: "here" }). Because this library uses reject to indicate that the update failed, I can't write a test that asserts that I show an appropriate error message in case of failure.

I think this should be changed in Ember, but if they're going to hold firm, we should probably change it here.

@jamesarosen jamesarosen changed the title Cannot test failure case in tests Cannot test failure modes Jul 22, 2015
@jamesarosen
Copy link
Author

In the meantime, one solution that @iezer came up with was to wrap the result in Ember.Error, which bypasses the fail test on promise rejection logic:

if (response.error) {
  Ember.run(null, reject, new Ember.Error(response.code));
}

Edit: this does not work. We had something else disguising the problem.

@joshsmith
Copy link
Contributor

@jamesarosen ah, I remember this well. I think I opened the issue in ember-simple-auth that led to that chain.

What's your proposed solution for this right now? It's been over a year since my head was wrapped around that problem and haven't encountered it since.

Meanwhile, it looks like you may have made significant progress in your understanding of the problem/solution based on that thread.

@jamesarosen
Copy link
Author

The fallout of that Ember issue was that the core team added some tests to ensure that a rejected promise doesn't fail the tests, but an uncaught rejected promise does. So the application code should somehow account for the possible rejection.

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