Skip to content
\n

And we get the following errors:

\n
console.error\n      Error: Error: connect ECONNREFUSED 127.0.0.1:80\n          at Object.dispatchError (<omitted>/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:63:19)\n          at Request.<anonymous> (<omitted>/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:655:18)\n          at Request.emit (node:events:539:35)\n          at ClientRequest.<anonymous> (<omitted>/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:121:14)\n          at ClientRequest.emit (node:events:527:28)\n          at Socket.socketErrorListener (node:_http_client:454:9)\n          at Socket.emit (node:events:527:28)\n          at emitErrorNT (node:internal/streams/destroy:157:8)\n          at emitErrorCloseNT (node:internal/streams/destroy:122:3)\n          at processTicksAndRejections (node:internal/process/task_queues:83:21) undefined\n\n      at VirtualConsole.<anonymous> (node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/virtual-console.js:29:45)\n\n    console.warn\n      Aborted(both async and sync fetching of the wasm failed)\n\n      at E (node_modules/jeep-sqlite/dist/cjs/node_modules/sql.js/dist/sql-wasm.js:101:136)\n      at ab (node_modules/jeep-sqlite/dist/cjs/node_modules/sql.js/dist/sql-wasm.js:102:149)\n      at node_modules/jeep-sqlite/dist/cjs/node_modules/sql.js/dist/sql-wasm.js:103:256\n\n    console.warn\n      failed to asynchronously prepare wasm: RuntimeError: Aborted(both async and sync fetching of the wasm failed). Build with -sASSERTIONS for more info.\n\n      at node_modules/jeep-sqlite/dist/cjs/node_modules/sql.js/dist/sql-wasm.js:158:377\n\n    console.warn\n      Aborted(RuntimeError: Aborted(both async and sync fetching of the wasm failed). Build with -sASSERTIONS for more info.)\n\n      at E (node_modules/jeep-sqlite/dist/cjs/node_modules/sql.js/dist/sql-wasm.js:101:136)\n      at node_modules/jeep-sqlite/dist/cjs/node_modules/sql.js/dist/sql-wasm.js:158:425\n\n  ● getLookupRecordData › updateOfflineData › test db\n\n    both async and sync fetching of the wasm failed\n\n      at Object.Module.onAbort (node_modules/jeep-sqlite/dist/cjs/node_modules/sql.js/dist/sql-wasm.js:40:20)\n      at E (node_modules/jeep-sqlite/dist/cjs/node_modules/sql.js/dist/sql-wasm.js:101:106)\n      at ab (node_modules/jeep-sqlite/dist/cjs/node_modules/sql.js/dist/sql-wasm.js:102:149)\n      at node_modules/jeep-sqlite/dist/cjs/node_modules/sql.js/dist/sql-wasm.js:103:256\n\n  ● getLookupRecordData › updateOfflineData › test db\n\n    RuntimeError: Aborted(RuntimeError: Aborted(both async and sync fetching of the wasm failed). Build with -sASSERTIONS for more info.). Build with -sASSERTIONS for more info.\n\n      at E (node_modules/jeep-sqlite/dist/cjs/node_modules/sql.js/dist/sql-wasm.js:101:154)\n      at node_modules/jeep-sqlite/dist/cjs/node_modules/sql.js/dist/sql-wasm.js:158:425\n
\n

So I guess a two questions:

\n
    \n
  1. Is there anything that stands out as wrong above code?
  2. \n
  3. Is there are preferred way to run jeep-sql lite in Jest (ie do we need mount the component within JSDom, or some other machanism?)
  4. \n
  5. Are there any common gotchas when testing with jeep-sql?
  6. \n
\n

Any hints would be highly appreciated! Thanks!

","upvoteCount":3,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

Hello, sorry for the late answer.

\n

Yes I did find an answer. The solution that worked was spinning up a server before running the test. So we added the following scripts to our package.json:

\n
  \"scripts\": {\n    \"serve\": \"cp node_modules/sql.js/dist/sql-wasm.wasm build/assets && serve -l 80 build/\",\n    \"test\": \"{Your test script here}\",\n    \"test:serve\": \"npm-run-all --parallel -r serve test\", \n  },\n
\n

Then we ran npm run test:serve when running the test. The test:serve script serves a local host that jeepSqlite is trying to reach out to in order to retrieve the sql-wasm.wasm file.

","upvoteCount":0,"url":"https://github.com/capacitor-community/sqlite/discussions/406#discussioncomment-6015025"}}}
Discussion options

You must be logged in to vote

Hello, sorry for the late answer.

Yes I did find an answer. The solution that worked was spinning up a server before running the test. So we added the following scripts to our package.json:

  "scripts": {
    "serve": "cp node_modules/sql.js/dist/sql-wasm.wasm build/assets && serve -l 80 build/",
    "test": "{Your test script here}",
    "test:serve": "npm-run-all --parallel -r serve test", 
  },

Then we ran npm run test:serve when running the test. The test:serve script serves a local host that jeepSqlite is trying to reach out to in order to retrieve the sql-wasm.wasm file.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jepiqueau
Comment options

@Brandi-Youreka
Comment options

Answer selected by Brandi-Youreka
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants