scanclient/tests/app.spec.js
2021-03-14 19:06:51 +01:00

44 lines
1.0 KiB
JavaScript

const {Application} = require('spectron');
const {strict: assert} = require('assert');
const {join} = require('path');
const app = new Application({
path: require('electron'),
requireName: 'electronRequire',
args: [join(__dirname, '../dist/source')],
});
app.start()
.then(async () => {
const isVisible = await app.browserWindow.isVisible();
assert.ok(isVisible, 'Main window not visible');
})
.then(async () => {
const isDevtoolsOpen = await app.webContents.isDevToolsOpened();
assert.ok(!isDevtoolsOpen, 'DevTools opened');
})
.then(async function () {
// Get the window content
const content = await app.client.$('#app');
assert.notStrictEqual(await content.getHTML(), '<div id="app"></div>', 'Window content is empty');
})
.then(function () {
if (app && app.isRunning()) {
return app.stop();
}
})
.then(() => process.exit(0))
.catch(function (error) {
console.error(error);
if (app && app.isRunning()) {
app.stop();
}
process.exit(1);
});