javascript - ChaiJS expect constructor to throw error -
i trying test constructor throw error using teaspoon gem rails, chaijs assertion library.
when run following test:
it('does not create seat if x < 0', function() { var badconstructor = function() { return new seat({ radius: 10, x: -0.1, y: 0.2, seat_number: 20, table_number: 30}); }; expect(badconstructor).to.throw(error, 'invalid location'); });
i output:
failures:
1) seat not create seat if x < 0 failure/error: undefined not constructor (evaluating 'expect(badconstructor).to.throw(error(), 'invalid location')')
the constructor throwing error, think not writing test properly.
when try running expect(badconstructor())
output:
failures: 1) seat not create seat if x < 0 failure/error: invalid location
had same problem. wrap constructor function:
var fcn = function(){new badconstructor()}; expect(fcn).to.throw(error, 'invalid location');
Comments
Post a Comment