Update test configs

This commit is contained in:
Jesse Hines 2025-08-03 14:21:26 -04:00
parent 08ffc26dce
commit 66ca2bfc37
No known key found for this signature in database
5 changed files with 84 additions and 71 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
.obsidian-cache
.env
# Don't include the compiled main.js file in the repo.
# They should be uploaded to GitHub releases instead.
main.js

1
package-lock.json generated
View file

@ -27,6 +27,7 @@
"chai": "^5.2.1",
"esbuild": "^0.25.8",
"eslint": "^9.32.0",
"lodash.merge": "^4.6.2",
"mocha": "^11.7.1",
"npm-run-all": "^4.1.5",
"obsidian": "latest",

View file

@ -11,8 +11,8 @@
"lint": "eslint src test",
"test": "run-s test:*",
"test:unit": "tsc --noEmit && mocha",
"test:e2e": "npm run build && npx wdio run ./wdio.conf.mts",
"test-extra:android": "npm run build && npx wdio run ./wdio.mobile.conf.mts"
"test:e2e": "npx wdio run ./wdio.conf.mts",
"test-extra:android": "npx wdio run ./wdio.mobile.conf.mts"
},
"keywords": [],
"author": "",
@ -33,6 +33,7 @@
"chai": "^5.2.1",
"esbuild": "^0.25.8",
"eslint": "^9.32.0",
"lodash.merge": "^4.6.2",
"mocha": "^11.7.1",
"npm-run-all": "^4.1.5",
"obsidian": "latest",

View file

@ -1,46 +1,33 @@
import * as path from "path"
import { obsidianBetaAvailable, resolveObsidianVersions } from "wdio-obsidian-service";
import { parseObsidianVersions, obsidianBetaAvailable } from "wdio-obsidian-service";
import merge from "lodash.merge";
import { env } from "process";
// wdio-obsidian-service will download Obsidian versions into this directory
const cacheDir = path.resolve(".obsidian-cache");
let versions: [string, string][]; // [appVersion, installerVersion][]
if (process.env.OBSIDIAN_VERSIONS) {
// Space separated list of appVersion/installerVersion, e.g. "1.7.7/latest latest/earliest"
versions = process.env.OBSIDIAN_VERSIONS.split(/[ ,]+/).map(v => {
const [app, installer = "earliest"] = v.split("/"); // default to earliest installer
return [app, installer];
})
} else if (process.env.CI) {
// Running in GitHub CI. You can use RUNNER_OS to select different versions on different
// platforms in the workflow matrix if you want
versions = [["earliest", "earliest"], ["latest", "latest"]];
if (await obsidianBetaAvailable(cacheDir)) {
versions.push(["latest-beta", "latest"]);
// choose Obsidian versions to test
let defaultVersions = "earliest/earliest latest/latest";
if (await obsidianBetaAvailable({cacheDir})) {
defaultVersions += " latest-beta/latest"
}
const desktopVersions = await parseObsidianVersions(
env.OBSIDIAN_VERSIONS ?? defaultVersions,
{cacheDir},
);
const mobileVersions = await parseObsidianVersions(
env.OBSIDIAN_MOBILE_VERSIONS ?? env.OBSIDIAN_VERSIONS ?? defaultVersions,
{cacheDir},
);
if (env.CI) {
// Print the resolved Obsidian versions to use as the workflow cache key
// (see .github/workflows/test.yaml)
for (let [app, installer] of versions) {
[app, installer] = await resolveObsidianVersions(app, installer, cacheDir);
console.log(`${app}/${installer}`);
}
} else {
versions = [["earliest", "earliest"], ["latest", "latest"]];
console.log("obsidian-cache-key:", JSON.stringify([desktopVersions, mobileVersions]));
}
export const config: WebdriverIO.Config = {
runner: 'local',
framework: 'mocha',
specs: ['./test/specs/**/*.e2e.ts'],
// How many instances of Obsidian should be launched in parallel during testing.
maxInstances: Number(process.env["WDIO_MAX_INSTANCES"] || 4),
capabilities: versions.flatMap(([appVersion, installerVersion]) => {
const common: WebdriverIO.Capabilities = {
browserName: 'obsidian',
browserVersion: appVersion,
'wdio:obsidianOptions': {
installerVersion: installerVersion,
plugins: [
".",
{id: "obsidian-excalidraw-plugin", enabled: false},
@ -50,38 +37,50 @@ export const config: WebdriverIO.Config = {
vault: "./test/vault",
},
}
return [
{...common},
{
...common,
export const config: WebdriverIO.Config = {
runner: 'local',
framework: 'mocha',
specs: ['./test/specs/**/*.e2e.ts'],
// How many instances of Obsidian should be launched in parallel during testing.
maxInstances: Number(env.WDIO_MAX_INSTANCES || 4),
// "matrix" to test your plugin on multiple Obsidian versions and with emulateMobile
capabilities: [
...desktopVersions.map(([appVersion, installerVersion]) => merge({}, common, {
'wdio:obsidianOptions': {
...common['wdio:obsidianOptions'],
appVersion, installerVersion,
},
})),
// Test the plugin on the emulated mobile UI.
...mobileVersions.map(([appVersion, installerVersion]) => merge({}, common, {
'wdio:obsidianOptions': {
appVersion, installerVersion,
emulateMobile: true,
},
'goog:chromeOptions': {
mobileEmulation: {
// can also set deviceName: "iPad" etc. instead of hard-coding size
deviceMetrics: {width: 390, height: 844, touch: false},
},
},
},
]
}),
})),
],
services: ["obsidian"],
reporters: ['obsidian'],
cacheDir: cacheDir,
bail: 2,
mochaOpts: {
ui: 'bdd',
timeout: 60000,
// Retry flaky tests
// TODO: Fix the timing issues
timeout: 60 * 1000,
retries: 4,
bail: true,
},
waitforInterval: 250,
waitforTimeout: 5 * 1000,
logLevel: "warn",
cacheDir: cacheDir,
}

View file

@ -1,30 +1,40 @@
import * as path from "path"
import { parseObsidianVersions } from "wdio-obsidian-service";
import { env } from "process";
let versionsToTest: string[]
if (process.env.OBSIDIAN_VERSIONS) {
versionsToTest = process.env.OBSIDIAN_VERSIONS.split(/[ ,]+/)
} else {
versionsToTest = ["earliest", "latest"];
const cacheDir = path.resolve(".obsidian-cache");
// choose Obsidian versions to test
// note: beta versions aren't available for the Android app
let defaultVersions = "earliest/earliest latest/latest";
const versions = await parseObsidianVersions(
env.OBSIDIAN_MOBILE_VERSIONS ?? env.OBSIDIAN_VERSIONS ?? defaultVersions,
{cacheDir},
);
if (env.CI) {
console.log("obsidian-cache-key:", JSON.stringify(versions));
}
export const config: WebdriverIO.Config = {
runner: 'local',
framework: 'mocha',
maxInstances: 1, // can't do android tests in parallel :(
specs: ['./test/specs/**/*.e2e.ts'],
hostname: 'localhost',
port: parseInt(process.env.APPIUM_PORT || "4723"),
maxInstances: 1, // Parallel tests don't work under appium
hostname: env.APPIUM_HOST || 'localhost',
port: parseInt(env.APPIUM_PORT || "4723"),
capabilities: versionsToTest.map((version) => ({
// (installerVersion isn't relevant for the mobile app)
capabilities: versions.map<WebdriverIO.Capabilities>(([appVersion]) => ({
browserName: "obsidian",
browserVersion: version,
platformName: 'Android',
'appium:automationName': 'UiAutomator2',
'appium:avd': "obsidian_test",
'appium:enforceAppInstall': true,
'appium:adbExecTimeout': 60 * 1000,
'wdio:obsidianOptions': {
appVersion: appVersion,
plugins: [
".",
{id: "obsidian-excalidraw-plugin", enabled: false},
@ -43,15 +53,16 @@ export const config: WebdriverIO.Config = {
],
reporters: ["obsidian"],
cacheDir: path.resolve(".obsidian-cache"),
bail: 2,
mochaOpts: {
ui: 'bdd',
timeout: 60000,
timeout: 60 * 1000,
retries: 4,
bail: true,
},
waitforInterval: 250,
waitforTimeout: 5 * 1000,
logLevel: "warn",
cacheDir: cacheDir,
}