-
-
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
assert.throws fails in component integration tests with ember 2.12 #256
Comments
workarounds/solutions by @workmanw:
|
You can also solve this problem by using import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('dummy-component', 'Unit | Component | dummy component', {
unit: true,
});
test('it throws', function(assert) {
assert.throws(() => {
this.subject({ /* attributes */ });
}, 'Error: Assertion Failed: Someone forgot to provide a required value attribute');
}); This has the advantage that it doesn't require an extra library, and uses a unit test instead of an integration test. |
It looks like https://github.com/workmanw/ember-qunit-assert-helpers is the best solution for now. |
is there any way to do this w/o extra libraries using the newer test style? |
This happens in utils test. I cant test for error throwing. test('it throws if params are empty', function(assert) {
const missingFirst = () => {
throw new Error('foo');
};
assert.throws(missingFirst(), 'param 1 missing');
}); |
I installed Ember 2.12 and created new project with a component and a test to ensure it throws an error if required attribute is not provided. I can't get this test to pass.
dummy-component.js
dummy-component.hbs
dummy-component-test.js
Error:
Also asked here
http://stackoverflow.com/questions/42978212/ember-qunit-assert-throws-does-not-work
The text was updated successfully, but these errors were encountered: