CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-dcloudio--uni-automator

Automated testing framework for uni-app projects enabling cross-platform testing across H5, WeChat mini-programs, and mobile apps

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

launcher.mddocs/

Application Launcher

Core functionality for initializing and configuring the automation testing environment across different uni-app platforms.

Capabilities

Launch Function

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"
    }
  }
});

Launch Configuration

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;
}

H5 Platform Options

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
    }
  }
});

App Plus Platform Options

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"
    }
  }
});

WeChat Mini-Program Options

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"
  }
});

Baidu Mini-Program Options

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;
}

Platform Requirements

H5 Platform

  • Dependency: puppeteer (peer dependency)
  • Node.js: Version 10.18.1+ (required by Puppeteer v3.0.0+)
  • Browser: Chromium-based browser for Puppeteer

App Plus Platform

  • Android:
    • adbkit peer dependency
    • Global adb environment variable configured
    • Android APK file (HBuilder debug/custom base)
  • iOS:
    • node-simctl peer dependency
    • macOS with Xcode installed
    • iOS Simulator configured

WeChat Mini-Program Platform

  • WeChat Developer Tools: Installed and accessible via CLI
  • Project Configuration: Valid project.config.json and WeChat appid
  • Auto Port: Available port for WebSocket communication

Baidu Mini-Program Platform

  • Baidu Developer Tools: Installed and accessible via CLI
  • Limited Support: Basic functionality only

Error Handling

/**
 * 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:

  • CLI_NOT_FOUND: Vue CLI or platform-specific CLI tools not found
  • CONNECTION_FAILED: Unable to connect to platform runtime
  • COMPILATION_FAILED: Project compilation errors
  • PLATFORM_NOT_SUPPORTED: Unsupported platform specified
  • PORT_IN_USE: Specified port already occupied

Install with Tessl CLI

npx tessl i tessl/npm-dcloudio--uni-automator

docs

element.md

index.md

launcher.md

page.md

program.md

tile.json