-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Cannot get electron.remote.require to work #29
Comments
It seems that |
I've got a few questions:
|
I've tried to create an example which is as minimal as possible (not easy), I've uploaded it to https://github.com/michelwilson/karma-electron-minimal-example. The uploaded version works in The error I get is:
|
Great, that helped a bunch! Here's what the issues I found:
To summarize, the following fixes should resolve everything but we recommend the launcher karma.conf.js: // ...
preprocessors: {
'src/**/*.js': ['electron'],
'test/**/*.js': ['electron']
},
client: {
useIframe: false,
loadScriptsViaRequire: true
},
// ... script.js: // ...
node_script = require('electron').remote.require(__dirname + '/../main.js');
// ... |
Ah that gives some insight. I've got the minimal example working, now. To get the actual application to work, a bit more is required, as the I am not sure what use the launcher |
Well, I don't fully understand why, but I got things working. For anyone encountering similar problems (you never know, and I hate finding problems without solutions ;)):
No idea if this is the 'right' way, but it makes it work for me :) Thanks for the assistance! |
Glad to hear we got it working. If you'd like, I can help direct you in the direction with respect to |
In case of the real application, |
Cool, thanks for the info. Here's a few options:
|
Interesting reading, thanks! I particularly like the idea of contract-based fixtures, as this circumvents the problem of not really testing the API by explicitly defining it. Even gives you a form of documentation for the API :) Thanks! I believe that I'll continue to use the current approach, due to time/budget constraints, unfortuntely. However, there'll always be future projects :) |
I'm trying to get an angularjs-app, which I package with electron, to play together with karma-electron. Previously we used PhantomJS, but I would like to move away from this. The problem is that in a couple of places I have a
require('electron').remote.require('./main.js')
to get access to some Node stuff from within the renderer process. I cannot seem to get this to work. Using the full path ofmain.js
makes it work, but that is (obviously) undesirable.I have set
__filenameOverride
to the location ofindex.html
andloadScriptsViaRequire
is set totrue
. Doesn't seem to make a difference. Clearly, therequire
is looking in the wrong place for my script (it's in the same directory asindex.html
). What magic is required to get it working? Issue #11 seems to suggest that it should just work, but doesn't provide me with the detail to get it working in my case...The text was updated successfully, but these errors were encountered: