Closed brettz9 closed 8 years ago
FWIW, I did that for the IndexedDB tests last year for exactly the reason you described (running in Node and in the browser, and testing is way faster and more convenient if it doesn't rely on a browser). So you're not the only one who feels that way.
I'm not sure if it's a common enough use case for many people to care about it, though.
Given the ubiquity of client-side JavaScript, and the resulting popularity of server-side JavaScript for code reuse, I think that if critical mass can be reached, there is great potential for IndexedDB APIs become available for various databases.
And FYI, another repo did the same thing you mentioned, perhaps indicating at least some other interest out there (not to mentioned indexeddb-js if not others) but I'd like to avoid the maintenance headache of keeping them in sync... And it's not like two duplicate sets of files would need to be maintained...
I hadn't noticed that other project... but it is actually forked from mine :)
Given the ubiquity of client-side JavaScript, and the resulting popularity of server-side JavaScript for code reuse, I think that if critical mass can be reached, there is great potential for IndexedDB APIs become available for various databases.
I kind of agree, that was one of the reasons for my project. I don't know if it's particularly likely because of how painful the IndexedDB API is to use. But that's what they said about JavaScript itself...
And, there is the potential for libraries ala jQuery to make it easier on both ends... db.js, Dexie, etc.
I think moving the JavaScript into external files alone would be useful, as one might be able to monkey-patch the rest to work with Node. I also like using the same exact testing framework and support methods. Would there be openness to a PR? If so, I assume just adding them to a "js" child directory would be fine?
For now, I'm using cheerio to just extract the script content into their own files and see if I can adapt (monkey-patching where possible) the testing library to run the files in Node.
FWIW, I've integrated this stand-off approach into master
of IndexedDBShim (in the "test-support" directory with web-platform-tests as a submodule).
Some of the web APIs are also very convenient for use in Node.js or elsewhere.
I'm personally interested in IndexedDB (I'm currently working with IndexedDBShim) and would like to have a means of importing the tests without needing to do HTML parsing to extract out the tests and adapt them for Node usage.
If the tests can be structured independently of HTML, it is more likely those of us working on server APIs can contribute back to the tests, as well as to even potentially popularize the use of the web-based APIs in the browser by facilitating code reuse from the server to browser.
Thanks!