通过与咕噜集成约曼量角器 [英] Integrating Protractor with Yeoman via Grunt
问题描述
我要量角器与约曼公司生产的支架集成。我也跟着教程以及其中,用于建立端到端的测试上了年纪情景亚军
(通过咕噜
)。
我想升级我的脚手架,用量角器来代替。结果
有什么想法?
-
安装
量角器
和咕噜-量角器亚军
从NPM
:NPM安装量角器咕噜-量角器亚军--save-dev的
-
创建量角器一个配置文件(
protractor.conf.js
),更改规格
和的baseUrl
来测试文件和测试服务器:exports.config = {
seleniumAddress:HTTP://本地主机:4444 / WD /中心,
规格:['测试/ E2E / * _ test.js'],
的baseUrl:HTTP://本地主机:9001'//默认的测试端口约曼
} -
更新
Gruntfile.js
,添加以下的业力任务之后:量角器:{
选项:{
KEEPALIVE:真实,
CONFIGFILE:protractor.conf.js
},
跑: {}
} -
添加量角器任务测试
grunt.registerTask(测试,[
干净:服务器',
并发:测试',
自动prefixer',
连接:测试',
'因果报应',
量角器:运行
]); -
下载并启动硒服务器:
node_modules /量角器/斌/ webdriver的经理更新
node_modules /量角器/斌/ webdriver的经理开始(在Windows中:)
节点node_modules /量角器/斌/ webdriver的经理更新
节点node_modules /量角器/斌/ webdriver的经理开始 -
更新
的package.json
,添加以下后devDependencies
。这之后将运行命令NPM安装
,这样你就不需要记住每一次。脚本:{
安装:节点node_modules /量角器/斌/ webdriver的经理更新
} -
使用咕噜运行测试
咕噜测试
如果你想量角器来启动服务器给你,删除
seleniumAddress:HTTP://本地主机:4444 / WD /中心,
从 protractor.conf.js
,然后运行咕噜测试
将在测试期间启动一个独立硒实例运行测试套件之后退出了。
I want to integrate Protractor with a scaffold produced by Yeoman. I followed a tutorial and therein, the older scenario-runner
was used for setting up e2e testing (via grunt
).
I would like to upgrade my scaffold and use Protractor instead.
Any thoughts?
Install
protractor
andgrunt-protractor-runner
fromnpm
:npm install protractor grunt-protractor-runner --save-dev
Create a config file for protractor (
protractor.conf.js
), changespecs
andbaseUrl
to your test files and test server:exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['test/e2e/*_test.js'], baseUrl: 'http://localhost:9001' //default test port with Yeoman }
Update your
Gruntfile.js
, add the following after the karma task:protractor: { options: { keepAlive: true, configFile: "protractor.conf.js" }, run: {} }
Add the protractor task under test
grunt.registerTask('test', [ 'clean:server', 'concurrent:test', 'autoprefixer', 'connect:test', 'karma', 'protractor:run' ]);
Download and start the selenium server:
node_modules/protractor/bin/webdriver-manager update node_modules/protractor/bin/webdriver-manager start
(In Windows:)
node node_modules/protractor/bin/webdriver-manager update node node_modules/protractor/bin/webdriver-manager start
Update your
package.json
, add the following after"devDependencies"
. This will run the command afternpm install
so you don't need to remember every time."scripts": { "install": "node node_modules/protractor/bin/webdriver-manager update" }
Run the test using grunt
grunt test
If you want protractor to start the server for you, remove
seleniumAddress: 'http://localhost:4444/wd/hub',
from protractor.conf.js
, then running grunt test
will start a standalone selenium instance during the test and quit it after running the test suite.
这篇关于通过与咕噜集成约曼量角器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!