Closed thiagodp closed 6 years ago
The drivers can be instantiated apart from database-js and tested that way. However it's probably best to test with database-js for completeness.
You can also load like this:
var jsondB = require('.'); // or the root to the driver project
var Connection = require('database-js');
var conn = new Connection('json:///mydata.json', jsondB);
If the second argument is passed, then the Connection constructor ignores the driver name in the connection URL or in a connection object.
Better using your way ;) (test updated)
It may worth it to make the drivers have only dev
dependencies on database-js
. I will open issues about that.
Database-js has drivers as separated projects. It does not need to include them as
dev
dependencies.On the other side, the drivers should include
database-js
as adev
dependency, for testing purposes (or they have to me maintained inside database-js, but never committed). However,database-js
loads the drivers according to thedriverName
, including (withrequire
) the respective file. Since the driver'sindex.js
is not insidedatabase-js
, it is not able to find it and, thus, to load the driver.There is a little hack, however, to solve this problem. I have used it in database-js-json, inside its mocha test file:
It would be nice having another solution to the driver loading problem. I the mean time, this hack can be useful to add proper tests in each driver project. @mlaanderson What do you think?