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

Remove exception method from QUnit test adapter. #307

Merged
merged 1 commit into from Jan 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 16 additions & 5 deletions addon-test-support/ember-qunit/adapter.js
@@ -1,5 +1,6 @@
import Ember from 'ember';
import QUnit from 'qunit';
import hasEmberVersion from '@ember/test-helpers/has-ember-version';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that helper public API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its effectively public, its basically in the same state as wait was before. Lots of folks use it, but we haven't officially said its "public".

I'll open a PR to export it from the entry point...


function unhandledRejectionAssertion(current, error) {
let message, source;
Expand All @@ -24,7 +25,7 @@ function unhandledRejectionAssertion(current, error) {
});
}

export default Ember.Test.Adapter.extend({
let Adapter = Ember.Test.Adapter.extend({
init() {
this.doneCallbacks = [];
},
Expand All @@ -40,8 +41,18 @@ export default Ember.Test.Adapter.extend({
done();
}
},

exception(error) {
unhandledRejectionAssertion(QUnit.config.current, error);
},
});

// Ember 2.17 and higher do not require the test adapter to have an `exception`
// method When `exception` is not present, the unhandled rejection is
// automatically re-thrown and will therefore hit QUnit's own global error
// handler (therefore appropriately causing test failure)
if (!hasEmberVersion(2, 17)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this condition sounds like it would only work for 2.17, but I'm assuming the same is true for 2.18?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasEmberVersion is basically like semver.gte for the provided major + minor.

Adapter = Adapter.extend({
exception(error) {
unhandledRejectionAssertion(QUnit.config.current, error);
},
});
}

export default Adapter;