Automated testing framework for uni-app projects enabling cross-platform testing across H5, WeChat mini-programs, and mobile apps
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Core functionality for initializing and configuring the automation testing environment across different uni-app platforms.
Main entry point for launching the automation testing environment. Handles platform detection, project compilation, and runtime connection establishment.
/**
* Launch the automation testing environment
* @param options - Platform and project configuration
* @returns Promise resolving to Program instance for test control
*/
function launch(options: LaunchOptions): Promise<Program>;Usage Examples:
const automator = require("@dcloudio/uni-automator");
// H5 platform testing
const program = await automator.launch({
platform: "h5",
projectPath: "/path/to/project",
h5: {
options: { headless: false }
}
});
// WeChat mini-program testing
const program = await automator.launch({
platform: "mp-weixin",
projectPath: "/path/to/project",
"mp-weixin": {
port: 9420,
launch: true
}
});
// App Plus (mobile) testing
const program = await automator.launch({
platform: "app-plus",
projectPath: "/path/to/project",
"app-plus": {
android: {
executablePath: "/path/to/android_base.apk"
}
}
});Comprehensive configuration options for different platforms and testing scenarios.
/**
* Launch configuration options
*/
interface LaunchOptions {
/** Target platform for testing */
platform: "h5" | "mp-weixin" | "app-plus" | "mp-baidu";
/** Path to the uni-app project directory */
projectPath?: string;
/** Path to Vue CLI or uni-app CLI tools */
cliPath?: string;
/** Connection timeout in milliseconds (default: 60000) */
timeout?: number;
/** Whether to compile the project before testing (default: auto-detect) */
compile?: boolean;
/** Suppress build output during compilation */
silent?: boolean;
/** H5-specific configuration options */
h5?: H5Options;
/** App Plus (mobile) configuration options */
"app-plus"?: AppPlusOptions;
/** WeChat mini-program configuration options */
"mp-weixin"?: WeChatOptions;
/** Baidu mini-program configuration options */
"mp-baidu"?: BaiduOptions;
}Configuration specific to H5/web platform testing using Puppeteer.
/**
* H5 platform configuration options
*/
interface H5Options {
/** Direct URL to skip project compilation */
url?: string;
/** Puppeteer browser options */
options?: {
/** Run browser in headless mode (default: true) */
headless?: boolean;
/** Additional Puppeteer launch options */
[key: string]: any;
};
}Usage Example:
const automator = require("@dcloudio/uni-automator");
const program = await automator.launch({
platform: "h5",
projectPath: "/path/to/project",
h5: {
url: "http://localhost:8080/h5/", // Skip compilation
options: {
headless: false, // Show browser window
slowMo: 50 // Slow down interactions
}
}
});Configuration for mobile app testing on iOS simulators and Android devices.
/**
* App Plus (mobile) platform configuration options
*/
interface AppPlusOptions {
/** Android device configuration */
android?: {
/** Path to Android APK file */
executablePath: string;
};
/** iOS simulator configuration */
ios?: {
/** iOS simulator UUID (required) */
id: string;
/** Path to iOS app bundle */
executablePath: string;
};
}Usage Example:
const automator = require("@dcloudio/uni-automator");
// Android testing
const program = await automator.launch({
platform: "app-plus",
"app-plus": {
android: {
executablePath: "/path/to/HBuilderX/plugins/launcher/base/android_base.apk"
}
}
});
// iOS simulator testing
const program = await automator.launch({
platform: "app-plus",
"app-plus": {
ios: {
id: "ABCD1234-5678-90EF-GHIJ-KLMNOPQRSTUV", // UUID from xcrun simctl list
executablePath: "/path/to/HBuilderX/plugins/launcher/base/Pandora_simulator.app"
}
}
});Configuration for WeChat mini-program testing using WeChat Developer Tools.
/**
* WeChat mini-program configuration options
*/
interface WeChatOptions {
/** WeChat Developer Tools port (default: 9420) */
port?: number;
/** Test account for mini-program testing */
account?: string;
/** Additional developer tools arguments */
args?: string;
/** Working directory for developer tools */
cwd?: string;
/** Auto-launch WeChat Developer Tools (default: true) */
launch?: boolean;
/** Teardown strategy after tests complete */
teardown?: "disconnect" | "close";
/** Enable remote debugging with QR code */
remote?: boolean;
/** Path to WeChat Developer Tools CLI */
executablePath?: string;
}Usage Example:
const automator = require("@dcloudio/uni-automator");
const program = await automator.launch({
platform: "mp-weixin",
"mp-weixin": {
port: 9420,
account: "test@example.com",
launch: true,
teardown: "disconnect",
remote: false,
executablePath: "/Applications/wechatwebdevtools.app/Contents/MacOS/cli"
}
});Configuration for Baidu Smart Program testing.
/**
* Baidu mini-program configuration options
*/
interface BaiduOptions {
/** Baidu Developer Tools port (default: 9430) */
port?: number;
/** Additional developer tools arguments */
args?: string;
/** Working directory for developer tools */
cwd?: string;
/** Auto-launch Baidu Developer Tools (default: true) */
launch?: boolean;
/** Teardown strategy after tests complete */
teardown?: "disconnect" | "close";
/** Enable remote debugging */
remote?: boolean;
/** Path to Baidu Developer Tools CLI */
executablePath?: string;
}puppeteer (peer dependency)adbkit peer dependencyadb environment variable configurednode-simctl peer dependencyproject.config.json and WeChat appid/**
* Common errors thrown during launch
*/
interface LaunchError extends Error {
code: "PLATFORM_NOT_SUPPORTED" | "CLI_NOT_FOUND" | "CONNECTION_FAILED" | "COMPILATION_FAILED";
platform?: string;
details?: string;
}Common launch failures:
Install with Tessl CLI
npx tessl i tessl/npm-dcloudio--uni-automator