You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I've tried to find a way by reading the current documentation to get a handle to the context of my main.js module, somehow.
It's is very elegant to test UI features, but it would be great to be able to use Spectron for all unit tests, but I can't find a way at the moment to do this.
For example, say that I have I have a function foo in my main.js (or in anything it has a reference to),I'd like to write a unit test that would look a bit like this;
it 'should just work ffs', (done)->
app.getMagicReferenceToMainJs().then (main)->
bar = main.foo()
expect(bar).to.equal(4711)
done()
In such a case, what would the magic function be named (or what should I use to the same effect)?
Thanks for any help!
The text was updated successfully, but these errors were encountered:
It's not ideal, but what you could do is create regular unit tests files apart from your Spectron tests and mock the electron api you depend on, for example, If your code relies on `app.getPath('userData') you could create a mock like:
I need the same thing but for a (very) slightly different reason. My app opens files, and I want to cause files to be opened from my tests. I would like to be able to do:
it('should open a file',()=>{app.mainScopeOrWhatever.openFile('/path/to/file')app.browserWindow.isVisible().then(function(visible){console.log('window is visible? '+visible)})})
where my main.js has:
functionopenFile(path){// ...}
I wouldn't even mind having to explicitly deliver openFile to the tests inside main.js with something like:
Hi, I've tried to find a way by reading the current documentation to get a handle to the context of my main.js module, somehow.
It's is very elegant to test UI features, but it would be great to be able to use Spectron for all unit tests, but I can't find a way at the moment to do this.
For example, say that I have I have a function foo in my main.js (or in anything it has a reference to),I'd like to write a unit test that would look a bit like this;
it 'should just work ffs', (done)->
app.getMagicReferenceToMainJs().then (main)->
bar = main.foo()
expect(bar).to.equal(4711)
done()
In such a case, what would the magic function be named (or what should I use to the same effect)?
Thanks for any help!
The text was updated successfully, but these errors were encountered: