Unable to write passing unit test for inserting object with Linq2IndexedDB

Apr 15, 2013 at 12:43 PM
Edited Apr 15, 2013 at 12:54 PM
Hi guys

For a project I've been trying out Linq2IndexedDB as an alternative to raw IndexedDB, but am at an impasse as I am plain unable to make Linq2IndexedDB work in my unit tests (using the Mocha framework and the Karma runner). I've tested simple insertion with three browsers on Windows so far: PhantomJS, Chrome and IE 10. Linq2IndexedDB fails every time in ways unique to each browser.

I get the following errors for each browser:
  • Phantom (somewhere within initialize()): INVALID_ACCESS_ERR: DOM Exception 15: A parameter or an operation was not supported by the underlying object.
  • Chrome (within IDBVersionChangeHandler.request.onversionchange, around line 1535): TypeError: Cannot read property 'version' of undefined
  • IE 10 (within insert()): Linq2IndexedDB: An external key is provided while the object store expects a keyPath key.DataErrorinsertDataError
I have published my test project on Github, if anyone would like to try. There's a single unit test (of database insertion) on line 51 of test/dbSpec.js and Karma is configured to run tests in Chrome, PhantomJS and IE. The README contains specific instructions on how to run the tests via Karma.

I'd appreciate very much if anyone would take the time to try my project and help me in making Linq2IndexedDB work!

I initially posted a stackoverflow question if anyone would like to come up with an answer there.

Apr 21, 2013 at 9:47 PM
I finally got it working under Chrome and IE 10, although PhantomJS is still proving troublesome, as per my answer on stackoverflow. Note that I had to specify the schema to make things work under Chrome, this looks like a bug in Linq2IndexedDB.
Apr 21, 2013 at 10:08 PM
Fixed it for PhantomJS as well, by disabling Linq2IndexedDB's debug logging. Not sure why this would break things, but it did.
Apr 22, 2013 at 5:46 AM

Sorry, for my late awnser, but I have been busy IRL lately.

One of the know issues is the fact that my logging is causing memory leaks, This is because I also put the indexeddb object in to my logging, makes it easier to debug. (Maybe it shoul be an option :))

It would look odd if disabling the logging would solve your problem, I'll try to take a look at it with your code ASAP.