I'm writing an integration test that checks if a form displays errors. The assertions pass, but I get the error: <DS.Errors:ember1402>. Since this is expected behavior, how should I handle this?
test('users cannot create an empty level', function() {
visit('/collaborate/game/430/levels/new');
click('.submit-level'); // I submit it without filling anything in
andThen(function() {
var errorText = find('.error').text();
var blankText = errorText.match(/can't be blank/);
// these pass:
notEqual(errorText.length, 0);
equal(blankText.length, 1);
});
});
I saw throws in the QUnit API Docs, so I added throws to my test:
test('users cannot create an empty level', function() {
visit('/collaborate/game/430/levels/new');
throws(function() {
click('.submit-level');
}, 'has thrown an error');
andThen(function() {
var errorText = find('.error').text();
var blankText = errorText.match(/can't be blank/);
notEqual(errorText.length, 0);
equal(blankText.length, 1);
});
});
This simply throws another error. I want to either expect the error, or simply ignore it.
How do I handle expected errors in my tests?
Aucun commentaire:
Enregistrer un commentaire