spectron测试配置Skill spectron-test-setup

本技能用于为已弃用的遗留Electron桌面应用程序配置和搭建Spectron自动化测试环境。它能够生成测试结构、集成WebDriverIO、管理应用生命周期并创建页面对象模型。关键词:Electron测试,Spectron,自动化测试,遗留系统,WebDriverIO,测试配置。

测试 0 次安装 0 次浏览 更新于 2/25/2026

name: spectron-test-setup description: 为遗留Electron应用设置Spectron(已弃用)测试 allowed-tools: Read, Write, Edit, Bash, Glob, Grep tags: [electron, testing, spectron, legacy, deprecated]

spectron-test-setup

为遗留Electron应用程序设置Spectron测试。注意:Spectron已弃用;新项目请使用Playwright。

能力

  • 配置Spectron测试环境
  • 生成测试结构
  • 设置WebDriverIO集成
  • 处理应用程序生命周期
  • 创建页面对象

输入模式

{
  "type": "object",
  "properties": {
    "projectPath": { "type": "string" },
    "electronPath": { "type": "string" }
  },
  "required": ["projectPath"]
}

测试示例

const Application = require('spectron').Application;
const path = require('path');

describe('应用程序启动', function () {
  beforeEach(function () {
    this.app = new Application({
      path: require('electron'),
      args: [path.join(__dirname, '..')]
    });
    return this.app.start();
  });

  afterEach(function () {
    if (this.app && this.app.isRunning()) {
      return this.app.stop();
    }
  });

  it('显示初始窗口', function () {
    return this.app.client.getWindowCount().then(count => {
      expect(count).toBe(1);
    });
  });
});

迁移说明

考虑迁移到 playwright-electron-config 以进行现代化的Electron测试。

相关技能

  • playwright-electron-config
  • electron-mock-factory