Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

desktop: take app screenshot if test fails

Abdullah Attadaa60939c3d1
diff --git a/.github/workflows/desktop.tests.yml b/.github/workflows/desktop.tests.yml
index ca1f78cbb..61aed2e57 100644
--- a/.github/workflows/desktop.tests.yml
+++ b/.github/workflows/desktop.tests.yml
@@ -79,6 +79,14 @@ jobs:
EXECUTABLE_PATH=output/mac/Notesnook.app/Contents/MacOS/Notesnook npm run test
working-directory: ./apps/desktop
+ - name: Upload test results
+ uses: actions/upload-artifact@v4
+ if: failure()
+ with:
+ name: test-results-macos
+ path: apps/desktop/test-results
+ retention-days: 5
+
test-linux:
name: Test for Linux
needs: build
diff --git a/apps/desktop/__tests__/launch.test.mjs b/apps/desktop/__tests__/launch.test.mjs
index 2416913d8..2391a2223 100644
--- a/apps/desktop/__tests__/launch.test.mjs
+++ b/apps/desktop/__tests__/launch.test.mjs
@@ -20,21 +20,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import test from "node:test";
import { launchApp } from "./utils.mjs";
import assert from "assert";
+import slugify from "slugify";
+import path from "path";
+import { mkdir } from "fs/promises";
-test("make sure app loads", async () => {
+test("make sure app loads", async (t) => {
const { app, page } = await launchApp();
-
- await page.waitForSelector("#authForm");
-
- assert.ok(
- await page.getByRole("button", { name: "Create account" }).isVisible()
- );
-
- await page
- .getByRole("button", { name: "Skip & go directly to the app" })
- .click();
-
- await page.waitForSelector(".ProseMirror");
-
- await app.close();
+ try {
+ await page.waitForSelector("#authForm");
+
+ assert.ok(
+ await page.getByRole("button", { name: "Create account" }).isVisible()
+ );
+
+ await page
+ .getByRole("button", { name: "Skip & go directly to the app" })
+ .click();
+
+ await page.waitForSelector(".ProseMirror");
+ } catch (e) {
+ await mkdir("test-results", { recursive: true });
+ await page.screenshot({
+ path: path.join(
+ "test-results",
+ `${slugify(t.name)}-${process.platform}-${process.arch}-error.png`
+ )
+ });
+ throw e;
+ } finally {
+ await app.close();
+ }
});
diff --git a/apps/desktop/package-lock.json b/apps/desktop/package-lock.json
index 2a733cb30..941394258 100644
--- a/apps/desktop/package-lock.json
+++ b/apps/desktop/package-lock.json
@@ -35,6 +35,7 @@
"node-gyp-build": "^4.8.2",
"playwright": "^1.48.2",
"prebuildify": "^6.0.1",
+ "slugify": "^1.6.6",
"tree-kill": "^1.2.2",
"undici": "^6.19.8",
"vitest": "^2.1.5"
@@ -6324,6 +6325,16 @@
"node": ">=8"
}
},
+ "node_modules/slugify": {
+ "version": "1.6.6",
+ "resolved": "https://registry.npmjs.org/slugify/-/slugify-1.6.6.tgz",
+ "integrity": "sha512-h+z7HKHYXj6wJU+AnS/+IH8Uh9fdcX1Lrhg1/VMdf9PwoBQXFcXiAdsy2tSK0P6gKwJLXp02r90ahUCqHk9rrw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8.0.0"
+ }
+ },
"node_modules/smart-buffer": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index 00e0940d1..5c2bce599 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -50,6 +50,7 @@
"node-gyp-build": "^4.8.2",
"playwright": "^1.48.2",
"prebuildify": "^6.0.1",
+ "slugify": "^1.6.6",
"tree-kill": "^1.2.2",
"undici": "^6.19.8",
"vitest": "^2.1.5"