Qunit assert throws not working


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) {

function () {
  fillIn('#a8n-signon-card-number input', '2342314');
  fillIn('#a8n-signon-password input', 'password');
  click('#a8n-signon-submit-button button');
"Error Thrown"

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


There’s a workaround on the issue in Github located here you might try: https://github.com/emberjs/ember-qunit/issues/256

From nickiaconis’ comment:

"Here’s a work-around for QUnit:

import Ember from ‘ember’; import QUnit from ‘qunit’; import { QUnitAdapter } from ‘ember-qunit’;

// Work-around for https://github.com/emberjs/ember.js/issues/15013 const originalAssertThrows = QUnit.assert.throws; const rethrowAdapter = QUnitAdapter.extend({ exception(error) { throw error; }, }).create(); QUnit.assert.throws = () => { const originalAdapter = Ember.Test.adapter; Ember.Test.adapter = rethrowAdapter;

originalAssertThrows.apply(this, arguments);

Ember.Test.adapter = originalAdapter; };"