Skip to content

Commit dfa57d6

Browse files
committed
Restructure Electron E2E test
1 parent 7de8366 commit dfa57d6

File tree

4 files changed

+23
-26
lines changed

4 files changed

+23
-26
lines changed

e2e/electron-test/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
content="default-src 'self'; script-src 'self'"
99
/>
1010
<link href="index.css" rel="stylesheet" />
11-
<title>Hello from nut.js!</title>
11+
<title>nut.js Electron test</title>
1212
</head>
1313
<body style="width: 100%; height: 100%">
1414
<div id="content">

e2e/electron-test/main.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const { app, ipcMain, BrowserWindow } = require("electron");
22
const { getActiveWindow } = require("@nut-tree/nut-js");
33
const path = require("path");
4-
const assert = require("assert");
54

65
const title = "nut.js Electron test";
76

@@ -18,21 +17,21 @@ function createWindow() {
1817
});
1918
mainWindow.loadFile(path.join(__dirname, "index.html"));
2019
mainWindow.maximize();
21-
22-
(async () => {
20+
mainWindow.once("show", () => {
2321
// GIVEN
24-
const foregroundWindow = await getActiveWindow();
25-
26-
// WHEN
27-
const windowTitle = await foregroundWindow.title;
28-
29-
// THEN
30-
assert.strictEqual(
31-
windowTitle,
32-
title,
33-
`Wrong foreground window. Expected ${title}, got ${windowTitle}`
34-
);
35-
})();
22+
getActiveWindow().then((foregroundWindow) => {
23+
// WHEN
24+
foregroundWindow.title.then((windowTitle) => {
25+
// THEN
26+
if (windowTitle !== title) {
27+
console.error(
28+
`Wrong foreground window. Expected ${title}, got ${windowTitle}`
29+
);
30+
process.exit(-1);
31+
}
32+
});
33+
});
34+
});
3635
}
3736

3837
ipcMain.on("main", (event, args) => {

e2e/electron-test/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99
"url": "https://s1h.org"
1010
},
1111
"scripts": {
12-
"pretest": "electron-rebuild && electron-rebuild -m ../../",
1312
"test": "electron ."
1413
},
1514
"license": "MIT",
1615
"devDependencies": {
1716
"electron": "^13.1.6",
18-
"electron-rebuild": "^2.3.5",
1917
"@nut-tree/nut-js": "file:../../"
2018
}
2119
}

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)