Open karlulricsimon opened 8 years ago
In addition to this, when I try to run a stand-alone test with mocha and chai, I get TypeError: Cannot read property 'isMinimized' of undefined
. Would anyone know why this example from the documentation is failing or why browserWindow is undefined? I run the test by calling mocha test.js
. Besides the different path to my electron app, the test file is copied and pasted.
In addition to this, when I try to run a stand-alone test with mocha and chai, I get TypeError: Cannot read property 'isMinimized' of undefined.
Does your electron app have node integration enabled?
Thanks for your response. I am generating the app using nativefier. Node integration is disabled on the app. Adding if (process.env.NODE_ENV === 'test') { window.electronRequire = require }
to preload.js doesn't seem to impact the tests. I was hoping to use nativefier to produce a desktop version of a webapp I'm working on without needing to maintain two separate projects. This route is less appealing if I cant use the same tests to verify that both web and desktop versions of the app are functioning in the same ways. Do you have any thoughts or recommendations on how I might be able to get this working?
I had a similar issue and it took me a lot to work it out. In my test suite I was having:
beforeEach(function () {
this.app = new Application({
path: '/usr/local/bin/electron',
args: [
path.join(__dirname, '..')
],
});
return this.app.start();
});
After I changed it to include the entry point script it worked:
beforeEach(function () {
this.app = new Application({
path: '/usr/local/bin/electron',
args: [
path.join(__dirname, '..', 'main.js')
],
});
return this.app.start();
});
Can we get a response on this issue @kevinsawicki ? It seems like Spectron was not designed for use with WDIO testrunner. I have had no success trying to use my existing WebdriverIO test framework with Spectron.
Can we use browser WDIO in spectron?
I am adapting an existing test suite (using mocha and chai/chai as promised) using WDIO Testrunner to use an electron version of the app the tests were originally written for. The example in the documentation of a test with chai as promised does not use a test runner file, just a standalone test, nor can I find an example of WDIO Testrunner being used elsewhere in the documentation. Is it possible to use WDIO Testrunner in conjunction with Spectron? When I try to configure the testrunner file to use the electron app instead of chrome (via chromeOptions: {binary: 'path'}), the app launches, but all tests timeout and fail.
The documentation indicates that Spectron exposes the client property of an Application instance. The current set of tests I have use the browser global object. How are these two objects related, and is there some straight-forward way of converting these objects? There also does not seem to be a clear cut way of exposing the client property from the test runner file itself, is this correct?
From a maintainability perspective, it would be really beneficial if I could simply write a different Testrunner file specific to the electron app that utilises the same underlying test files as the web app. Is this possible?
Here's my Testrunner file and an example of the tests I am trying to run:
wdio.conf.js
Example test
``` describe("Menu tests", function() { console.log('\nMenu Tests:') // check Menu visibility describe("Menu visibility", function() { it("should be visible", function() { return browser .openApp() // contained in app_extensions.js .isVisible('.menu').should.eventually.be.true .isVisible('#dropdownModelsMenu').should.eventually.be.true; }); }); // check Model submenu describe("Models Menu", function(){ var modelsMenuId = "#dropdownModelsMenu"; var modelsSubMenu = ["#open-model", "#import-model", "#save-project", "#export-model", "#delete-project"]; it("should open the submenu", function() { return browser .openApp() .waitForEnabled(modelsMenuId) .click(modelsMenuId) .waitForVisible(modelsSubMenu[0]) .isVisible(modelsSubMenu[0]).should.eventually.be.true .isVisible(modelsSubMenu[1]).should.eventually.be.true .isVisible(modelsSubMenu[2]).should.eventually.be.true .isVisible(modelsSubMenu[3]).should.eventually.be.true .isVisible(modelsSubMenu[4]).should.eventually.be.true; }); it("should disable submenu options when model not loaded", function() { return browser .openApp() .waitForEnabled(modelsMenuId) .click(modelsMenuId) .getAttribute(modelsSubMenu[2], 'class').should.eventually.contain('disabled') .getAttribute(modelsSubMenu[3], 'class').should.eventually.contain('disabled') .getAttribute(modelsSubMenu[4], 'class').should.eventually.contain('disabled'); }); }); }); ``` I have been looking into this over the past few days haven't met much with success. Any help would be greatly appreciated. Thanks.