diff --git a/Makefile b/Makefile index 17c738c0..b313533a 100644 --- a/Makefile +++ b/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" -# 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 diff --git a/tests/spectron/runner.spec.ts b/tests/spectron/runner.spec.ts index e693b50e..98f7c3e5 100644 --- a/tests/spectron/runner.spec.ts +++ b/tests/spectron/runner.spec.ts @@ -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, - args: ['--no-sandbox', '.'], - }); - - return app.start(); + const app = new Application({ + path: (electronPath as unknown) as string, + args: ['--no-sandbox', '.'], }); - after('app:stop', function () { + before('app:start', async () => { + await app.start(); + }); + + 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'); });