-
-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get tests running under Node.js with IndexedDBShim #701
Comments
Just a quick update that I’m working on this. Made some progress using node-qunit but that wasn’t picking up the async tests (it’s not actively maintained and I didn’t deep dive into why it wasn’t working). Instead, I just got the first batch of test (in tests-table.js) to run under Node using qunit-tap (after seeing this comment by @leobalter – thanks, Leo.) Currently, it’s a terrible hack (I was just trying to get it working) and I’ve hardcoded some browser-based globals that dexie-unittest-utils.js was setting, etc. I also replaced the imports with requires to get it working. Next step: going to try and make a test runner that doesn’t require any code changes on the existing tests. Will keep this issue updated on my progress and push a brach to my fork when I have something a bit more presentable. PS. Currently, all tests in tests_table.js are passing under Node, except for test 5 ( |
Global IDBKeyRange was used in WhereClause.
Thanks a lot for looking into this. The tests will definitely need to be converted to universal JS in one or other way. I just looked up the issue with IDBKeyRange, and found a few locations in WhereClause. Should be the only ones using it. It's now fixed in master. |
Awesome news on the IDBKeyRange issues. Going to start working on a very minimalist test runner for Node now. Basically, my plan is to:
🤞 |
Thanks! Whatever method you choose to make it run on node, I'm extraordinary happy. Maybe rollup could be of some help with the bundling of all modules into a single CommonJS based one? Currently the test suite is bundled using rollup config in Edit: the rollup config file currently outputs UMD format, which should detect commonjs and use require() where needed. To make it even more clean, that config file would probably be better off using |
@dfahlander, I just got all the tests running with a custom test runner for Dexie/Node :) Going to issue a pull request in a few minutes – please don’t merge that (I need to update the code styles to fit the project, etc.) Just issuing it so you can take a look. It makes a best effort to get through the whole test suite (and does) but some tests are failing and others are timing out. It feels like a good start though :) |
@dfahlander When you’ve had a chance to look at the test results, can you please let me know what your thoughts are on the current state of Dexie on Node with IndexedDBShim. Do you see any major issues? (I will look through the results also but I’m, of course, not as familiar with the project as you are.) Would be great, once you have some time, to triage the fixes. I hope the tests help and if there’s anything more I can do, please let me know. I’d really like to use this production on Indie Site unless you see major concerns/showstoppers :) |
Yes, I will have a look as soon as possible. Please remind me if no feedback from me tomorrow morning. |
@dfahlander Thanks, David. I’m in the process of creating a single issue that summarises all of the issues in a single place to hopefully make your life easier :) |
Tried your branch but got Repro:
|
I wonder if that’s because I added IndexedDBShim as a dev dependency? Nuking my node_modules now and doing a fresh |
Hmm, just nuked node_modules and did a fresh npm install. It’s not that… Update: Also did an |
What Node version are you running? (grasping at straws here, but who knows…) I’m on a Mac (latest High Sierra) running node v8.11.1 and npm version 6.0.1. Update: And I’m using nvm… I wonder if its linked in the SQLite native module somehow on my machine independent of the local npm install. |
I'll try remove node_modules and retry... |
Still issue but I'll upgrade node and npm... I'm also on mac high sierra. |
Got your test suite for node running! Thanks! Analyse
SummaryMost operations goes fine. All basic normal stuff seems to work, even IndexedDB 2.0 features such as binary keys, are supported, but beware the following:
|
@dfahlander Thank you so much, I’m still in the middle of creating a separate issue with all the test failures for easy reference (got interrupted). Your analysis and summary are invaluable. Hugely appreciate it :) |
The table and collection sorting/ordering-related issues might be related to indexeddbshim/IndexedDBShim#296 |
I think indexeddbshim/IndexedDBShim#296 regards more to that native async/await commits too early. As long as the tests stick to using the global.Promise or Dexie.Promise, and transpile async/await instead of using native raw async/await, this should not be an error as Dexie works around this exact same issue (in Firefox, IE + older versions of Edge and Safari). |
I’ve confirmed that the tests are, in fact, using Dexie.Promise (via |
I am suspecting a collation issue in the websql module maybe. IndexedDB assumes ordinal sort while it may be the case that sqlite defaults to another collation. Just a theory though. |
This will hopefully resolve the ordering issue listed in dexie/Dexie.js#709 dexie/Dexie.js#701
It’s possible to run Dexie under Node using IndexedDBShim (#359 (comment)), however, we do not know for certain that it behaves as expected as the test suite currently only runs in the browser environment.
Given that IndexedDBShim currently has some issues under Node, it would be good to know whether and how it effects expected behaviour in Dexie.
@dfahlander Do you have any thoughts on a strategy to make the test suite isomorphic so that it can be run under both browsers and Node?
The text was updated successfully, but these errors were encountered: