Unit Test Dexie/Angular with Jasmine

576 views
Skip to first unread message

robjb...@gmail.com

unread,
Mar 8, 2016, 4:55:26 PM3/8/16
to Dexie.js
I have an Angular app that I have Jasmine tests for. I would like to add tests for the service that uses Dexie but I cannot get the returned promises to resolve.

I have tried various wrapping with $q in the service, and then calling $rootScope.$digest() in the test but nothing I try works.

Has anyone got a working example of this.

Many Thanks

www.s...@gmail.com

unread,
Apr 18, 2016, 6:33:51 AM4/18/16
to Dexie.js, robjb...@gmail.com
Have you tried $rootScope.$apply()?

www.s...@gmail.com

unread,
Apr 19, 2016, 7:37:35 AM4/19/16
to Dexie.js, robjb...@gmail.com
On Wednesday, March 9, 2016 at 3:25:26 AM UTC+5:30, robjb...@gmail.com wrote:

Without wrapping with $q, you can force the test to wait until the promises have completed, by using the Jasmine's async test pattern. E.g.:

it("can have table names with special characters", function (done) {
db.version(1).stores({
"SpecialRecord:Suffix": "id++,name"
});
db.open()
.then(function (v) {
console.info("Done!");
done();
})
.catch(function (err) {
throw Error(err.toString());
});
});

Reply all
Reply to author
Forward
0 new messages