Simplify spectron tests

Change-type: patch
This commit is contained in:
Alexis Svinartchouk 2020-06-04 12:41:31 +02:00
parent 28f9954661
commit 7e7a669116
2 changed files with 14 additions and 28 deletions

View File

@ -164,10 +164,8 @@ lint: lint-ts lint-sass lint-cpp lint-spell
MOCHA_OPTIONS=--recursive --reporter spec --require ts-node/register --require-main "tests/gui/allow-renderer-process-reuse.ts"
# See https://github.com/electron/spectron/issues/127
ETCHER_SPECTRON_ENTRYPOINT ?= $(shell node -e 'console.log(require("electron"))')
test-spectron:
ETCHER_SPECTRON_ENTRYPOINT="$(ETCHER_SPECTRON_ENTRYPOINT)" mocha $(MOCHA_OPTIONS) tests/spectron/runner.spec.ts
mocha $(MOCHA_OPTIONS) tests/spectron/runner.spec.ts
test-gui:
electron-mocha $(MOCHA_OPTIONS) --full-trace --no-sandbox --renderer tests/gui/**/*.ts

View File

@ -16,41 +16,29 @@
import { expect } from 'chai';
import { Application } from 'spectron';
import * as EXIT_CODES from '../../lib/shared/exit-codes';
const entrypoint = process.env.ETCHER_SPECTRON_ENTRYPOINT;
if (!entrypoint) {
console.error('You need to properly configure ETCHER_SPECTRON_ENTRYPOINT');
process.exit(EXIT_CODES.GENERAL_ERROR);
}
import * as electronPath from 'electron';
describe('Spectron', function () {
// Mainly for CI jobs
this.timeout(40000);
let app: Application;
before('app:start', function () {
app = new Application({
path: entrypoint,
const app = new Application({
path: (electronPath as unknown) as string,
args: ['--no-sandbox', '.'],
});
return app.start();
before('app:start', async () => {
await app.start();
});
after('app:stop', function () {
after('app:stop', async () => {
if (app && app.isRunning()) {
return app.stop();
await app.stop();
}
return Promise.resolve();
});
describe('Browser Window', function () {
it('should open a browser window', async function () {
describe('Browser Window', () => {
it('should open a browser window', async () => {
// We can't use `isVisible()` here as it won't work inside
// a Windows Docker container, but we can approximate it
// with these set of checks:
@ -61,7 +49,7 @@ describe('Spectron', function () {
expect(await app.browserWindow.isFocused()).to.be.true;
});
it('should set a proper title', async function () {
it('should set a proper title', async () => {
// @ts-ignore (SpectronClient.getTitle exists)
return expect(await app.client.getTitle()).to.equal('Etcher');
});