微信小程序自動化測試實驗


Mac環境准備:

  • Node.js +8.0
    • 方法一:在官方下載網站下載 pkg 安裝包,直接點擊安裝即可。
    • 方法二:用brew命令來安裝,brew install node
  • 基礎庫版本為2.7.3
  • 微信開發者工具版本1.02.1907232 及以上
  • jest框架
    • npm i jest -g

       

 

 

 

調用開發者工具命令行打開項目與指定自動化操作服務端口

$ ./cli --auto /Users/taiyingfu/Downloads/dist --auto-port 9420

Initializing...

idePortFile: /Users/taiyingfu/Library/Application Support/微信開發者工具/Default/.ide

IDE server has started, listening on http://127.0.0.1:58018

initialization finished

Open project with automation enabled success /Users/taiyingfu/Downloads/dist

  

講解:

1、要使用命令行調用工具,請打開工具 -> 設置 -> 安全設置,將服務端口開啟。

2、命令行所在位置:/Applications/wechatwebdevtools.app/Contents/Resources/app.nw/bin

3、自動化端口是獨立於服務端口的(比如終端打印出的35510其實是服務端口),必須要看到Open project with automation enabled success D:\weApp\testMiniprogram這行提示才算是成功打開了自動化端口(9420)。

4、命令運行成功后,開發者工具回自動打開項目,並彈出提示

 

 
實例:

npm i miniprogram-automator --save-dev安裝SDK,創建test.js,代碼中引入miniprogram-automator工具,連接自動化操作端口

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM