Qunit assert throws not working


#1

I am trying to assert that a few steps in the code (visiting page, providing wrong card-number, password combination and clicking submit)should generate an error from the backend service - I have referred to this already…

and tried the suggestion of using Error Object as the second argument to assert.throws but that doesn’t work for me.

Here’s my Qunit test

test('ERROR_CASE_visiting /signon, provide cardNumber(2342314) and ' +
'password, submit and expect to see invalid cardnumber/password error', 
function (assert) {

 assert.expect(2);
 assert.throws(
function () {
  visit('/signon');
  fillIn('#a8n-signon-card-number input', '2342314');
  fillIn('#a8n-signon-password input', 'password');
  click('#a8n-signon-submit-button button');
},
Error,
"Error Thrown"
 );
});

Is there anything else that i can try to get it to work.


#2

Once, I have encountered similar problem. Here is my problem

The solution was to use Ember.assert instead of throwing new error. And your test class you should use use assert.expectAssertion instead of assert.throws

ember-qunit-assert-helpers can be installed by command ember install ember-qunit-assert-helpers