fix/ e2e tests with Spectron

This commit is contained in:
Maxime GRIS
2020-08-12 22:21:04 +02:00
parent 84598a5146
commit 472afc8675
3 changed files with 16 additions and 16 deletions

View File

@@ -26,16 +26,13 @@ export default function setup(): void {
args: [path.join(__dirname, '..')], args: [path.join(__dirname, '..')],
webdriverOptions: {} 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()) { if (this.app && this.app.isRunning()) {
return this.app.stop(); await this.app.stop();
} }
}); });
} }

View File

@@ -4,19 +4,15 @@ import { SpectronClient } from 'spectron';
import commonSetup from './common-setup'; import commonSetup from './common-setup';
describe('angular-electron App', function () { describe('angular-electron App', function () {
commonSetup.apply(this); commonSetup.apply(this);
let browser: any;
let client: SpectronClient; let client: SpectronClient;
beforeEach(function () { beforeEach(async function() {
client = this.app.client; await this.app.start();
browser = client as any;
});
it('should display message saying App works !', async function () { client = this.app.client;
const text = await browser.getText('app-home h1');
expect(text).to.equal('App works !');
}); });
it('creates initial windows', async function () { it('creates initial windows', async function () {
@@ -24,4 +20,10 @@ describe('angular-electron App', function () {
expect(count).to.equal(1); 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 !');
});
}); });

View File

@@ -4,10 +4,11 @@
"outDir": "../out-tsc/e2e", "outDir": "../out-tsc/e2e",
"module": "commonjs", "module": "commonjs",
"types": [ "types": [
"mocha" "mocha",
"node"
] ]
}, },
"include": [ "include": [
"e2e/**/*.ts" "e2e/*.ts"
] ]
} }