-
Notifications
You must be signed in to change notification settings - Fork 229
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
Working docker image to run electron test headless #1021
Comments
I have made a little progress but I still cannot run the tests in the docker container. The above error meant my electron app did not even run .
Now I get a different error
My electron app did run this time. I can see the logs. I guess webdriver cannot connect to it. Any suggestions? |
Here are more logs
|
FYI, we just updated an app from Electron 11 to 13, and could no longer get Spectron to run the E2E tests in a Docker container. We spent half a day on trying to resolve this, but without luck. Here's the Dockerfile we're using, I think that's mostly just cobbled together from some places until it finally worked😀
As for getting the tests running: What we actually did now was switching to https://github.com/microsoft/playwright. I can't yet vouch for it, but the setup was incredibly easy. |
@GeorgDangl |
Yeah, exactly. We just have a handful of E2E tests, and we’re lucky to have a small abstraction layer for the Spectron API, so switching to it was quite fast. |
How did you run playWright headlessly ? microsoft/playwright#2609 Can you help me? |
Well, strictly speaking it doesn't run headless, it just runs in Docker with xvfb without showing an UI. So the Dockerfile and the entrypoint are similar to what you have. We've just got this for a common setup: const path = require('path');
import { ElectronApplication, _electron } from 'playwright';
export default function setup(): void {
beforeEach(async function () {
this.electronApp = await _electron.launch({
args: ['--disable_splash_screen', path.join(__dirname, '..')]
});
});
afterEach(function () {
if (this.electronApp) {
return this.electronApp.close();
}
});
} And then this (shortened) for the tests: import { E2eAppConfigService } from './e2e-app-config-service';
import { Page } from 'playwright';
import commonSetup from './common-setup';
import { expect } from 'chai';
describe('myproject-ui App', function () {
commonSetup.apply(this);
let page: Page;
let appConfig: { backendUrl: string };
beforeEach(async function () {
page = await this.electronApp.firstWindow();
appConfig = new E2eAppConfigService().getAppConfig();
await ensureUpdateCheckNotificationIsDisabled();
});
it('should display My Project Header in header', async function () {
const text = await getText('dangl-header h1');
expect(text).to.contain('some header text');
});
it('creates initial windows', async function () {
const windows = await this.electronApp.windows();
expect(windows.length).to.equal(1);
});
}); |
I've summarized it a bit here in this blog post: https://blog.dangl.me/archive/running-fully-automated-e2e-tests-in-electron-in-a-docker-container-with-playwright/ |
@GeorgDangl Thank you for sharing your post. I read your blog. But I still cannot get my tests to run. Are you able to give me so help? Have you ever run into |
Sorry, didn't run into that problem before, but I replied to your other issue in the Playwright repository. |
Hi,
Is there a working example of how to to run electron tests in a docker container headlessly?
What I have here does not work.
I can run my tests headlessly in the Ubuntu terminal.
This is the error.
The text was updated successfully, but these errors were encountered: