Skip to content

Commit 42708df

Browse files
Experiments/diagnostics (#4)
* Created a basic github workflow to run the webdriver.io tests on MacOS. * Worked out how to install pnpm so it can be used by the GitHub Action. * Added tests to debug why the original test stopped finding the element. * Added full path to enable REPL to work. --------- Co-authored-by: julianharty <julianharty@gmail.com>
1 parent 1807873 commit 42708df

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed

.github/workflows/test-e2e.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
name: E2E Tests
3+
4+
on:
5+
push:
6+
7+
env:
8+
CN_API_KEY: ${{ secrets.CN_API_KEY }}
9+
10+
jobs:
11+
test:
12+
runs-on: macos-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: "22"
21+
- name: Install pnpm
22+
uses: pnpm/action-setup@v4
23+
with:
24+
version: 10
25+
- name: Use Node.js 24
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 24
29+
cache: 'pnpm'
30+
31+
- name: Install dependencies
32+
run: pnpm install
33+
34+
- name: Install e2e dependencies
35+
run: pnpm install
36+
working-directory: e2e
37+
38+
- name: Run e2e integration tests
39+
run: pnpm test
40+
working-directory: e2e

e2e/test/specs/example.e2e.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,47 @@
1+
describe("Empty test", () => {
2+
it("should pass", async () => {
3+
console.info("Starting empty test");
4+
expect(true).toBe(true);
5+
browser.saveScreenshot("./empty-test.png");
6+
});
7+
});
8+
9+
describe("Minimal test", () => {
10+
it("should pass", async () => {
11+
console.info("Starting minimal test");
12+
const welcomeText = await $("[data-testid='welcome']").getText();
13+
expect(welcomeText).toBeDefined();
14+
expect(welcomeText).toContain("Welcome to Tauri + Solid!");
15+
console.info("Minimal test passed");
16+
await browser.saveScreenshot("./minimal-test.png");
17+
});
18+
});
19+
120
describe("Hello Tauri", () => {
221
it("should be excited", async () => {
22+
console.info("Starting test: should be excited");
323
await $("[data-testid='welcome']").waitForExist();
424
const header = await $("[data-testid='welcome']");
525
const text = await header.getText();
626
expect(text).toMatch(/!$/);
27+
console.info(`Found text: ${text}`);
728
});
29+
30+
describe("Hello Tauri using a Promise", () => {
31+
it("should be excited", async () => {
32+
console.info("Starting test: Hello Tauri using a Promise");
33+
const welcome = $("[data-testid='welcome']");
34+
35+
const foundElement = await Promise.race([
36+
welcome.waitForExist({timeout: 30000}).then(() => ({type: 'welcome', element: welcome}))
37+
])
38+
console.info(`Found ${foundElement.type} element`);
39+
await browser.saveScreenshot(`./${foundElement.type}-element-found.png`);
40+
const text = await foundElement.element.getText();
41+
expect(text).toMatch(/!$/);
42+
console.info(`Found text: ${text}`);
43+
});
44+
});
845
});
46+
47+

e2e/wdio.conf.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { waitTauriDriverReady } from "@crabnebula/tauri-driver";
55
import { fileURLToPath } from "url";
66

77
const __dirname = fileURLToPath(new URL(".", import.meta.url));
8+
const isMac = process.platform === 'darwin';
89

910
let tauriDriver;
1011
let exit = false;
@@ -17,12 +18,14 @@ export const config = {
1718
maxInstances: 1,
1819
capabilities: [
1920
{
21+
browserName: 'tauri',
22+
platformName: isMac ? 'macOS' : 'Windows',
2023
maxInstances: 1,
2124
"tauri:options": {
2225
application:
2326
process.platform === "darwin"
24-
? "../src-tauri/target/debug/bundle/macos/WebDriver Example.app"
25-
: "../src-tauri/target/debug/webdriver-example",
27+
? path.resolve(__dirname, "../src-tauri/target/debug/bundle/macos/WebDriver Example.app")
28+
: path.resolve(__dirname, "../src-tauri/target/debug/webdriver-example"),
2629
},
2730
},
2831
],

0 commit comments

Comments
 (0)