VUE2.0 測試環境配置


  • unit測試
安裝karma-chrome-luncher
npm install karma-chrome-launcher -save

在karma.conf.js中添加:

plugins: [
'karma-chrome-launcher',
'karma-mocha'
],
 

啟動測試

npm run unit
  • e2e測試

先安裝chromedriver 

npm install chromedriver

 nigtwatch.conf.js與runner.js文件不需要修改,默認即可 

npm run e2e 

在運行中報錯如下時

java.lang.UnsupportedClassVersionError: org/openqa/grid/selenium/GridLauncherV3 : Unsupporte
d major.minor version 52.0

 這里需要將JAVA換為對應版本

  stanford parser和jdk版本對應關系
J2SE 8 = 52, J2SE 7 = 51, J2SE 6.0 = 50, J2SE 5.0 = 49, JDK 1.4 = 48, JDK 1.3 = 47, JDK 1.2 = 46, JDK 1.1 = 45
運行出現瀏覽器閃退 報錯如下時
請查看根目錄下 selenium-debug.log文件,按log信息安裝匹配的chromedriver與chrome版本
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "e2e"
npm ERR! node v6.9.5
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! vue-project@1.0.0 e2e: `node test/e2e/runner.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-project@1.0.0 e2e script 'node test/e2e/runner.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the vue-project package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node test/e2e/runner.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs vue-project
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls vue-project
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     H:\vue-project\npm-debug.log

運行成功如下

Starting selenium server... started - PID:  22592

[Demo Test] Test Suite
==========================

[Test] Test Suite
=====================

Running:  default e2e tests
> Listening at http://localhost:8080

 √ Element <#app> was visible after 87 milliseconds.
 √ Testing if element <.hello> is present.
 √ Testing if element <h1> contains text: "Welcome to Your Vue.js App".
 √ Testing if element <img> has count: 1

OK. 4 assertions passed. (5.202s)

OK. 4  total assertions passed. (5.484s)

H:\vue-project>

 

 

 
 


免責聲明!

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



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