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
Build node-hid for use with electron, but now jest fails. #240
Comments
Hi @obiwanjacobi, Do you have a link to your project I can check out and try to help debug? I assume you are using Also, which bits of the README are out-of-date? I'll get that fixed ASAP and apologies for the confusion. |
No sorry, no public git repo yet. But if you drop me an email (obiwanjacobi@hotmail.com) I can zip you the project (I could not find your email). The readme says:
But electron-prebuild did not work / was not available. But without it, it still works. I did have 'electron' as a dependency though. |
I have isolated the problem in a separate project: HTH |
Hi @obiwanjacobi, |
Okay I think I found a solution to your issue.
This will both build the Typescript and run electron-rebuild. I'm not sure why you have |
I don't understand how that works. I execute 'npm run build' (because 'npm build' is reserved) but the problem still exists. Thanks. |
The But it seems like most Electron + Typescript examples I see have an explicit "build" step that invokes The The reason you need |
Ok, so I can have a postinstall script which does the tsc trans/compile and the electron-rebuild. Do I have to do an npm install for that to run (automatically after npm is finished installing) -or- can I just trigger it separately (and just execute tsc & electron-rebuild)? |
Yes, the problem is that jest is using your system Node and Electron is using its own version of Node. You need to tell jest to use Electron for its tests. It looks like someone had a similar issue here: jestjs/jest#3698 I made this change to my own checkout of
And the jest tests pass when I do "npm run test". I can edit files, run |
Hi,
As I was building up my app I had some integration tests working (jest) that tested my logic against the connected device - using node-hid. Worked fine.
Then I wanted to integrate that logic into the electron app and I had to rebuild - using the instructions in the read-me (that are not quite up-to-date anymore, btw) I got that working. My app logic execute fine in electron's main process.
However, the jest integration tests are now failing with a message "The specified module could not be found" followed by a path to a file: "\\?\C:[full path to my project root]\node_modules\node-hid\build\Release\HID.node" (there are no spaces in that path). The funny thing is that the file does exist, so my thought was that perhaps it could not read it correctly (because of the rebuild?)...?
Callstack:
at Runtime.requireModule (node_modules/jest-runtime/build/index.js:328:31)
at bindings (node_modules/bindings/bindings.js:81:44)
at Object. (node_modules/node-hid/nodehid.js:5:34)
Anyway, as this is my first TypeScript/JavaScript/electron/node-hid/react/etc. project, I am a bit lost as to where to look next. Any suggestions?
PS: I am aware that this may not even be a node-hid issue (but a jest issue) but this still seemed to logical place to start my investigation.
I'm on Windows 10.
The text was updated successfully, but these errors were encountered: