Bug Tracker

Modify

Ticket #4318 (closed feature: invalid)

Opened 4 years ago

Last modified 3 years ago

"raises" assertion for exception handling

Reported by: FND Owned by: joern
Priority: major Milestone:
Component: qunit Version:
Keywords: Cc:
Blocking: Blocked by:

Description

As suggested  here, QUnit could be extended with a raises assertion to test for the occurrence of exceptions.

The attached patch allows writing tests like the following:

var expression, expected;

// should pass
expression = function() { return foo.bar; };
expected = "TypeError";
throwsEx(expression, expected, "invalid property access raises
TypeError exception");

// should fail
expression = function() { var foo = {}; return foo.bar; };
expected = "NoneError";
throwsEx(expression, expected, "property access raises NoneError
exception");

(Note that these tests use closures to wrap around the expressions which are actually being tested.)

Attachments

QUnit_raisesAssertion.patch Download (1.1 KB) - added by FND 4 years ago.

Change History

Changed 4 years ago by FND

comment:1 Changed 3 years ago by john

  • Status changed from new to closed
  • Resolution set to invalid

We're moving QUnit-related bugs off to the new QUnit issue tracker:  http://github.com/jquery/qunit/issues

Please re-post the issue there.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.