Skip to content

Commit 472afc8

Browse files
author
Maxime GRIS
committed
fix/ e2e tests with Spectron
1 parent 84598a5 commit 472afc8

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

e2e/common-setup.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,13 @@ export default function setup(): void {
2626
args: [path.join(__dirname, '..')],
2727
webdriverOptions: {}
2828
});
29-
await this.app.start();
30-
const browser = this.app.client;
31-
await browser.waitUntilWindowLoaded();
3229

33-
browser.timeouts('script', 15000);
30+
await this.app.start();
3431
});
3532

36-
afterEach(function () {
33+
afterEach(async function () {
3734
if (this.app && this.app.isRunning()) {
38-
return this.app.stop();
35+
await this.app.stop();
3936
}
4037
});
4138
}

e2e/main.e2e.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,26 @@ import { SpectronClient } from 'spectron';
44
import commonSetup from './common-setup';
55

66
describe('angular-electron App', function () {
7+
78
commonSetup.apply(this);
89

9-
let browser: any;
1010
let client: SpectronClient;
1111

12-
beforeEach(function () {
13-
client = this.app.client;
14-
browser = client as any;
15-
});
12+
beforeEach(async function() {
13+
await this.app.start();
1614

17-
it('should display message saying App works !', async function () {
18-
const text = await browser.getText('app-home h1');
19-
expect(text).to.equal('App works !');
15+
client = this.app.client;
2016
});
2117

2218
it('creates initial windows', async function () {
2319
const count = await client.getWindowCount();
2420
expect(count).to.equal(1);
2521
});
2622

23+
it('should display message saying App works !', async function () {
24+
const elem = await client.$('app-home h1');
25+
const text = await elem.getText();
26+
expect(text).to.equal('App works !');
27+
});
28+
2729
});

e2e/tsconfig.e2e.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"outDir": "../out-tsc/e2e",
55
"module": "commonjs",
66
"types": [
7-
"mocha"
7+
"mocha",
8+
"node"
89
]
910
},
1011
"include": [
11-
"e2e/**/*.ts"
12+
"e2e/*.ts"
1213
]
1314
}

0 commit comments

Comments
 (0)