From 472afc867599ae57c34a33dd500df156bee4e628 Mon Sep 17 00:00:00 2001 From: Maxime GRIS Date: Wed, 12 Aug 2020 22:21:04 +0200 Subject: [PATCH] fix/ e2e tests with Spectron --- e2e/common-setup.ts | 9 +++------ e2e/main.e2e.ts | 18 ++++++++++-------- e2e/tsconfig.e2e.json | 5 +++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/e2e/common-setup.ts b/e2e/common-setup.ts index 577604d..ac5c2f0 100644 --- a/e2e/common-setup.ts +++ b/e2e/common-setup.ts @@ -26,16 +26,13 @@ export default function setup(): void { args: [path.join(__dirname, '..')], webdriverOptions: {} }); - await this.app.start(); - const browser = this.app.client; - await browser.waitUntilWindowLoaded(); - browser.timeouts('script', 15000); + await this.app.start(); }); - afterEach(function () { + afterEach(async function () { if (this.app && this.app.isRunning()) { - return this.app.stop(); + await this.app.stop(); } }); } diff --git a/e2e/main.e2e.ts b/e2e/main.e2e.ts index cc1780f..780249e 100644 --- a/e2e/main.e2e.ts +++ b/e2e/main.e2e.ts @@ -4,19 +4,15 @@ import { SpectronClient } from 'spectron'; import commonSetup from './common-setup'; describe('angular-electron App', function () { + commonSetup.apply(this); - let browser: any; let client: SpectronClient; - beforeEach(function () { - client = this.app.client; - browser = client as any; - }); + beforeEach(async function() { + await this.app.start(); - it('should display message saying App works !', async function () { - const text = await browser.getText('app-home h1'); - expect(text).to.equal('App works !'); + client = this.app.client; }); it('creates initial windows', async function () { @@ -24,4 +20,10 @@ describe('angular-electron App', function () { expect(count).to.equal(1); }); + it('should display message saying App works !', async function () { + const elem = await client.$('app-home h1'); + const text = await elem.getText(); + expect(text).to.equal('App works !'); + }); + }); diff --git a/e2e/tsconfig.e2e.json b/e2e/tsconfig.e2e.json index 9597947..c934903 100644 --- a/e2e/tsconfig.e2e.json +++ b/e2e/tsconfig.e2e.json @@ -4,10 +4,11 @@ "outDir": "../out-tsc/e2e", "module": "commonjs", "types": [ - "mocha" + "mocha", + "node" ] }, "include": [ - "e2e/**/*.ts" + "e2e/*.ts" ] }