Skip to content

Commit e4c2607

Browse files
committed
feat: use module, update dependencies, add shutdown hooks
1 parent 9da37db commit e4c2607

File tree

13 files changed

+5345
-3184
lines changed

13 files changed

+5345
-3184
lines changed

v1/webdriver/package.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

v1/webdriver/selenium/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
"version": "1.0.0",
44
"license": "Apache-2.0",
55
"private": true,
6+
"type": "module",
67
"scripts": {
78
"test": "mocha",
89
"format": "prettier --write \"./**/*.js\""
910
},
1011
"dependencies": {
11-
"chai": "^4.3.4",
12-
"mocha": "^9.0.0",
13-
"selenium-webdriver": "^4.0.0-beta.4"
12+
"chai": "^5.2.1",
13+
"mocha": "^11.7.1",
14+
"selenium-webdriver": "^4.34.0"
1415
}
1516
}

v1/webdriver/selenium/pnpm-lock.yaml

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

v1/webdriver/selenium/test/test.js

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
const os = require("os");
2-
const path = require("path");
3-
const { expect } = require("chai");
4-
const { spawn, spawnSync } = require("child_process");
5-
const { Builder, By, Capabilities } = require("selenium-webdriver");
1+
import os from "os";
2+
import path from "path";
3+
import { expect } from "chai";
4+
import { spawn, spawnSync } from "child_process";
5+
import { Builder, By, Capabilities } from "selenium-webdriver";
6+
import { fileURLToPath } from "url";
7+
8+
const __dirname = fileURLToPath(new URL(".", import.meta.url));
69

710
// create the path to the expected application binary
811
const application = path.resolve(
@@ -21,22 +24,22 @@ let driver;
2124

2225
// keep track of the tauri-driver process we start
2326
let tauriDriver;
27+
let exit = false;
2428

25-
before(async function() {
29+
before(async function () {
2630
// set timeout to 2 minutes to allow the program to build if it needs to
27-
this.timeout(120000)
31+
this.timeout(120000);
2832

2933
// ensure the program has been built
30-
spawnSync(
31-
"pnpm",
32-
["build"],
33-
{ cwd: path.resolve(__dirname, "../../.."), stdio: 'inherit', shell: true }
34-
)
35-
spawnSync(
36-
"cargo",
37-
["build", "--features", "tauri/custom-protocol"],
38-
{ cwd: path.resolve(__dirname, "../../../src-tauri"), stdio: 'inherit' }
39-
);
34+
spawnSync("pnpm", ["build"], {
35+
cwd: path.resolve(__dirname, "../../.."),
36+
stdio: "inherit",
37+
shell: true,
38+
});
39+
spawnSync("cargo", ["build", "--features", "tauri/custom-protocol"], {
40+
cwd: path.resolve(__dirname, "../../../src-tauri"),
41+
stdio: "inherit",
42+
});
4043

4144
// start tauri-driver
4245
tauriDriver = spawn(
@@ -56,7 +59,7 @@ before(async function() {
5659
.build();
5760
});
5861

59-
after(async function() {
62+
after(async function () {
6063
// stop the webdriver session
6164
await driver.quit();
6265

@@ -77,12 +80,14 @@ describe("Hello Tauri", () => {
7780

7881
it("should be easy on the eyes", async () => {
7982
// selenium returns color css values as rgb(r, g, b)
80-
const text = await driver.findElement(By.css("body")).getCssValue("background-color");
83+
const text = await driver
84+
.findElement(By.css("body"))
85+
.getCssValue("background-color");
8186

8287
const rgb = text.match(/^rgb\((?<r>\d+), (?<g>\d+), (?<b>\d+)\)$/).groups;
83-
expect(rgb).to.have.all.keys('r','g','b');
88+
expect(rgb).to.have.all.keys("r", "g", "b");
8489

85-
const luma = 0.2126 * rgb.r + 0.7152 * rgb.g + 0.0722 * rgb.b ;
86-
expect(luma).to.be.lessThan(100)
90+
const luma = 0.2126 * rgb.r + 0.7152 * rgb.g + 0.0722 * rgb.b;
91+
expect(luma).to.be.lessThan(100);
8792
});
8893
});

v1/webdriver/webdriverio/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
"version": "1.0.0",
44
"license": "Apache-2.0",
55
"private": true,
6+
"type": "module",
67
"scripts": {
78
"test": "wdio run wdio.conf.js",
89
"format": "prettier --write \"./**/*.js\""
910
},
1011
"devDependencies": {
11-
"@wdio/cli": "^7.7.3",
12-
"@wdio/local-runner": "^7.7.3",
13-
"@wdio/mocha-framework": "^7.7.3",
14-
"@wdio/spec-reporter": "^7.7.3"
12+
"@wdio/cli": "^9.19.0",
13+
"@wdio/local-runner": "^9.19.0",
14+
"@wdio/mocha-framework": "^9.19.0",
15+
"@wdio/spec-reporter": "^9.19.0"
1516
}
1617
}

0 commit comments

Comments
 (0)