VUE2.0 測試環境配置

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

在karma.conf.js中添加:vue

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

啓動測試java

npm run unit
  • e2e測試

先安裝chromedriver node

npm install chromedriver

 nigtwatch.conf.js與runner.js文件不須要修改,默認便可 chrome

npm run e2e 

在運行中報錯以下時npm

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

運行成功以下app

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>
 
相關文章
相關標籤/搜索