Skip to content

Commit

Permalink
fix/ e2e tests with Spectron
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime GRIS committed Aug 12, 2020
1 parent 84598a5 commit 472afc8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
9 changes: 3 additions & 6 deletions e2e/common-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
}
18 changes: 10 additions & 8 deletions e2e/main.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@ 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 () {
const count = await client.getWindowCount();
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 !');
});

});
5 changes: 3 additions & 2 deletions e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"types": [
"mocha"
"mocha",
"node"
]
},
"include": [
"e2e/**/*.ts"
"e2e/*.ts"
]
}

0 comments on commit 472afc8

Please sign in to comment.