Reputation: 25032
I am trying to get a project to work properly with Jasmine. I am using the project that I downloaded from here. I added another spec file, PatientSpec.js:
describe('Patient :: Create', function() {
it("Must note be null", function() {
require(['models/Patient'], function(Patient) {
var patient1 = new Patient();
expect(patient).toBeDefined();
});
});
});
You see that my var is named patient1
and I am running the expectation on the variable name patient
. When I look at my index.html, all of my tests are passing, and this is obviously not defined. I pull up my console and I here is my error:
What would cause this error? Why does it fail silently?
Upvotes: 0
Views: 1355
Reputation: 110892
It fails silently cause the error happens in the callback of your require
call not in your test. So when the error is thrown after your test has finished. You have to run your test inside of the callback:
require(['models/Patient'], function(Patient) {
describe('Patient :: Create', function() {
it("Must note be null", function() {
var patient1 = new Patient();
expect(patient).toBeDefined();
});
});
});
Take a look at this SO do understand how to test requireJs modules
Upvotes: 1