From 742095f13265c69efdaee1dd50ee3812ef7dae7f Mon Sep 17 00:00:00 2001 From: Maxime GRIS Date: Fri, 25 Jun 2021 17:21:39 +0200 Subject: [PATCH] fix/ spectron e2e test --- .eslintrc.json | 1 + e2e/common-setup.ts | 20 ++++---------------- e2e/main.e2e.ts | 6 +++--- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 863243af7..05c98f4bd 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -25,6 +25,7 @@ "plugin:@angular-eslint/template/process-inline-templates" ], "rules": { + "prefer-arrow/prefer-arrow-functions": 0, "@angular-eslint/directive-selector": 0, "@angular-eslint/component-selector": [ "error", diff --git a/e2e/common-setup.ts b/e2e/common-setup.ts index 0eb27f51e..68905783b 100644 --- a/e2e/common-setup.ts +++ b/e2e/common-setup.ts @@ -3,34 +3,22 @@ const ELECTRON_PATH = require('electron'); // Require Electron from the binaries const PATH = require('path'); export default function setup(): void { - beforeEach(async () => { + beforeEach(async function() { this.app = new APPLICATION({ // Your electron path can be any binary // i.e for OSX an example path could be '/Applications/MyApp.app/Contents/MacOS/MyApp' // But for the sake of the example we fetch it from our node_modules. path: ELECTRON_PATH, - - // Assuming you have the following directory structure - - // |__ my project - // |__ ... - // |__ main.js - // |__ package.json - // |__ index.html - // |__ ... - // |__ test - // |__ spec.js <- You are here! ~ Well you should be. - // The following line tells spectron to look and use the main.js file - // and the package.json located 1 level above. - args: [PATH.join(__dirname, '..')], + // and the package.json located in app folder. + args: [PATH.join(__dirname, '../app/main.js'), PATH.join(__dirname, '../app/package.json')], webdriverOptions: {} }); await this.app.start(); }); - afterEach(async () => { + afterEach(async function() { if (this.app && this.app.isRunning()) { await this.app.stop(); } diff --git a/e2e/main.e2e.ts b/e2e/main.e2e.ts index 8f992ef94..f79890ea0 100644 --- a/e2e/main.e2e.ts +++ b/e2e/main.e2e.ts @@ -3,7 +3,7 @@ import { SpectronClient } from 'spectron'; import commonSetup from './common-setup'; -describe('angular-electron App', () => { +describe('angular-electron App', function() { commonSetup.apply(this); @@ -13,12 +13,12 @@ describe('angular-electron App', () => { client = this.app.client; }); - it('creates initial windows', async () => { + it('creates initial windows', async function() { const count = await client.getWindowCount(); expect(count).to.equal(1); }); - it('should display message saying App works !', async () => { + 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 !');