42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import * as electron from 'electron';
|
|
import { expect } from 'chai';
|
|
import { Context } from 'mocha';
|
|
import rewiremock from 'rewiremock';
|
|
|
|
import 'mocha';
|
|
import { Application } from 'spectron';
|
|
|
|
rewiremock.disable();
|
|
|
|
describe('Application @spectron', function () {
|
|
this.timeout(20000);
|
|
|
|
interface IApplicationContext extends Context {
|
|
app?: Application;
|
|
}
|
|
|
|
// spectron writes its electron files into a temporary directory, the local app installation should not be compromised
|
|
before(function (this: IApplicationContext) {
|
|
this.app = new Application({
|
|
path: ((electron as unknown) as { default: string }).default,
|
|
args: ['.', '--enable-logging'],
|
|
});
|
|
return this.app.start();
|
|
});
|
|
|
|
after(function (this: IApplicationContext) {
|
|
if (this.app && this.app.isRunning()) {
|
|
return this.app.stop();
|
|
}
|
|
});
|
|
|
|
it('shows an initial window', function (this: IApplicationContext) {
|
|
if (!this.app) {
|
|
throw Error('this.app is falsy');
|
|
}
|
|
return this.app.client.getWindowCount().then((count: number) => {
|
|
expect(count).to.be.gte(1);
|
|
});
|
|
});
|
|
});
|