Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="QUnit - Excepciones" />
<link href="//code.jquery.com/qunit/qunit-git.css" rel="stylesheet" type="text/css" />
<script src="//code.jquery.com/qunit/qunit-git.js"></script>
  <meta charset="utf-8">
  <title>QUnit - Excepciones</title>
</head>
<body>
  
<div id="qunit"></div>  
<div id="qunit-fixture"></div> 
</body>
</html>
 
function esPar(num) {
  return num % 2 === 0;
}
QUnit.test('excepciones', function(assert) {
  assert.throws( function() { throw Error("Hola, soy un Error"); },
    'pasa al lanzar el Error');
  assert.throws( function() { x; }, // ReferenceError
    'pasa al no definir x, ');
  assert.throws( function() { esPar(2); },
    'falla porque no se lanza ningun Error');
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
aitormedran0pro
0viewers