mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-14 06:46:35 +00:00
Simplify spectron tests
Change-type: patch
This commit is contained in:
parent
28f9954661
commit
7e7a669116
4
Makefile
4
Makefile
@ -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"
|
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:
|
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:
|
test-gui:
|
||||||
electron-mocha $(MOCHA_OPTIONS) --full-trace --no-sandbox --renderer tests/gui/**/*.ts
|
electron-mocha $(MOCHA_OPTIONS) --full-trace --no-sandbox --renderer tests/gui/**/*.ts
|
||||||
|
@ -16,41 +16,29 @@
|
|||||||
|
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { Application } from 'spectron';
|
import { Application } from 'spectron';
|
||||||
|
import * as electronPath from 'electron';
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('Spectron', function () {
|
describe('Spectron', function () {
|
||||||
// Mainly for CI jobs
|
// Mainly for CI jobs
|
||||||
this.timeout(40000);
|
this.timeout(40000);
|
||||||
|
|
||||||
let app: Application;
|
const app = new Application({
|
||||||
|
path: (electronPath as unknown) as string,
|
||||||
before('app:start', function () {
|
args: ['--no-sandbox', '.'],
|
||||||
app = new Application({
|
|
||||||
path: entrypoint,
|
|
||||||
args: ['--no-sandbox', '.'],
|
|
||||||
});
|
|
||||||
|
|
||||||
return app.start();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after('app:stop', function () {
|
before('app:start', async () => {
|
||||||
|
await app.start();
|
||||||
|
});
|
||||||
|
|
||||||
|
after('app:stop', async () => {
|
||||||
if (app && app.isRunning()) {
|
if (app && app.isRunning()) {
|
||||||
return app.stop();
|
await app.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Browser Window', function () {
|
describe('Browser Window', () => {
|
||||||
it('should open a browser window', async function () {
|
it('should open a browser window', async () => {
|
||||||
// We can't use `isVisible()` here as it won't work inside
|
// We can't use `isVisible()` here as it won't work inside
|
||||||
// a Windows Docker container, but we can approximate it
|
// a Windows Docker container, but we can approximate it
|
||||||
// with these set of checks:
|
// with these set of checks:
|
||||||
@ -61,7 +49,7 @@ describe('Spectron', function () {
|
|||||||
expect(await app.browserWindow.isFocused()).to.be.true;
|
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)
|
// @ts-ignore (SpectronClient.getTitle exists)
|
||||||
return expect(await app.client.getTitle()).to.equal('Etcher');
|
return expect(await app.client.getTitle()).to.equal('Etcher');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user