feat: init electron e2e code source

This commit is contained in:
Amadou Ada DIENE
2020-04-20 01:56:15 +02:00
parent 8543cf148c
commit 45a02e392c
3 changed files with 66 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import * as path from 'path';
import { Application } from 'spectron';
describe('A simple test to verify a visible window is opened with a title', () => {
// Init local app
let app = new Application({
path: path.join(__dirname, '../../../node_modules/.bin/electron'),
args: [path.join(__dirname, '../../../dist/build/main.js')],
});
beforeAll(async () => {
// Init local app and wait until window loaded
await app.start();
await app.client.waitUntilWindowLoaded();
});
afterAll(async () => {
if (app && app.isRunning()) {
// Wait 1 second and then stop local app
await new Promise((resolve) => setTimeout(resolve, 1000));
await app.stop();
}
});
it('shows an initial window', async () => {
// Checking there is one visible window
expect(await app.browserWindow.isVisible()).toEqual(true);
// Please note that getWindowCount() will return 2 if `dev tools` are opened.
expect(await app.client.getWindowCount()).toEqual(1);
});
it('should have expected title', async () => {
expect(await app.client.getTitle()).toEqual('ElectronAngularQuickStart');
});
});