spectron
spectron copied to clipboard
Spectron is not renderering react app instead only a blank window is created
Hello, this bugging me for a while.
I am trying to implement e2e, I created an App using electron 11.2.1
Now I am trying to test it. Therefore I studied the docs and it seems that I don't need to take care of React rendering. however, this seems not to be the case.
Using (spectron 13
)
First I had this error where we need to set
webPreferences: {
enableRemoteModule: isDev, // Need that spectron will work
}
I was hoping that then the app would boot up.
Here are my current tests Nothing fancy just the first look. I also tried the same set up on a mini todo app and it did not work as well.
const Application = require('spectron').Application;
const electronPath = require('electron'); // Require Electron from the binaries included in node_modules.
const path = require('path');
const assert = require('assert');
describe('Start up Testing', function () {
this.timeout(100000);
beforeEach(() => {
this.app = new Application({
path: electronPath,
args: [path.join(__dirname, '..')],
});
return this.app.start();
});
afterEach(() => {
if (this.app && this.app.isRunning()) {
return this.app.stop();
}
});
it('shows an initial window', () => {
return this.app.client.getWindowCount().then(function (count) {
assert(count, 1);
});
});
it('the title is correct', () => {
const title = this.app.client.getTitle();
assert(title, 'MyApp');
});
});
To reproduce Fire up CRA, install electron 11.2.1 and spectron 13 set up a simple test script using mocha, and let it run.
Same issue:
electron: 11.2.2 spectron: 13.0.0 node: 14.15.4