2***@qq.com
2***@qq.com
  • 发布:2024-02-23 17:27
  • 更新:2024-02-29 19:22
  • 阅读:113

自动化测试 Failed to launch Wechat web devTools , please make sure http port is open

分类:uni-app

测试代码

describe('导航栏', () => {  
  let page  
  beforeAll(async () => {  
      // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)  
      page = await program.reLaunch('/pages/index/index')  
      await page.waitFor(10000)  
      console.log(page)  
  })  

  it('标题', async () => {  
      // 检测标题文本内容  
      expect(await (await page.$('.nav-bar__title-text')).text()).toBe('哈哈哈')  
  })  
})

jest.config.js

module.exports = {  
  testTimeout: 20000,  
  reporters: [  
      'default'  
  ],  
  watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],  
  moduleFileExtensions: ['js', 'json'],  
  rootDir: __dirname,  
  testMatch: ["<rootDir>/src/**/*test.[jt]s?(x)"],  
  testPathIgnorePatterns: ['/node_modules/'],  
  globalTeardown: '@dcloudio/uni-automator/dist/teardown.js',  
  testEnvironment: '@dcloudio/uni-automator/dist/environment.js',  
}  

执行命令

npm run test:mp-weixin

得到结果:Failed to launch Wechat web devTools , please make sure http port is open

2024-02-23 17:27 负责人:无 分享
已邀请:
DCloud_HB_WDL
  • 2***@qq.com (作者)

    这些已经全部打开了,依然显示Failed to launch Wechat web devTools , please make sure http port is open

    2024-02-26 13:42

JXWang

JXWang

需要在jest.config.js中配置微信开发工具cli路径等属性

 testEnvironmentOptions: {  
        compile: true,  
        h5: { // 为了节省测试时间,可以指定一个 H5 的 url 地址,若不指定,每次运行测试,会先 npm run dev:h5  
            options: {  
                headless: false // 配置是否显示 puppeteer 测试窗口  
            }  
        },  
        "app-plus": { // 需要安装 HBuilderX  
            android: {  
                appid: "", //自定义基座测试需配置manifest.json中的appid  
                package: "", //自定义基座测试需配置Android包名  
        "executablePath": "/Applications/HBuilderX-Dev.app/Contents/HBuilderX/plugins/launcher/base/android_base.apk"  
            },  
            ios: {  
                // uuid 必须配置,目前仅支持模拟器,可以(xcrun simctl list)查看要使用的模拟器 uuid  
        "id": "88E23FD4-D59B-46C8-BF89-C15586FE1507",  
        "executablePath": "/Applications/HBuilderX-Dev.app/Contents/HBuilderX/plugins/launcher/base/Pandora_simulator.app"  
            }  
        },  
        "mp-weixin": {  
            port: 9420, // 默认 9420  
            account: "", // 测试账号  
            args: "", // 指定开发者工具参数  
            cwd: "", // 指定开发者工具工作目录  
            launch: true, // 是否主动拉起开发者工具  
            teardown: "disconnect", // 可选值 "disconnect"|"close" 运行测试结束后,断开开发者工具或关闭开发者工具  
            remote: false, // 是否真机自动化测试  
      "executablePath": "/Applications/wechatwebdevtools.app/Contents/MacOS/cli"  
        },  
        "mp-baidu": {  
            port: 9430, // 默认 9430  
            args: "", // 指定开发者工具参数  
            cwd: "", // 指定开发者工具工作目录  
            launch: true, // 是否主动拉起开发者工具  
            teardown: "disconnect", // 可选值 "disconnect"|"close" 运行测试结束后,断开开发者工具或关闭开发者工具  
            remote: false, // 是否真机自动化测试  
            "executablePath": "" // 开发者工具cli路径,默认会自动查找    
        }  
    },

详见文档

要回复问题请先登录注册