通过与咕噜集成约曼量角器 [英] Integrating Protractor with Yeoman via Grunt

查看:204
本文介绍了通过与咕噜集成约曼量角器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要量角器与约曼公司生产的支架集成。我也跟着教程以及其中,用于建立端到端的测试上了年纪情景亚军(通过咕噜)。

我想升级我的脚手架,用量角器来代替。结果
有什么想法?


解决方案

  1. 安装量角器咕噜-量角器亚军 NPM

      NPM安装量角器咕噜-量角器亚军--save-dev的


  2. 创建量角器一个配置文件( protractor.conf.js ),更改规格的baseUrl 来测试文件和测试服务器:

      exports.config = {
      seleniumAddress:HTTP://本地主机:4444 / WD /中心,
      规格:['测试/ E2E / * _ test.js'],
      的baseUrl:HTTP://本地主机:9001'//默认的测试端口约曼
    }


  3. 更​​新 Gruntfile.js ,添加以下的业​​力任务之后:

     量角器:{
      选项​​:{
        KEEPALIVE:真实,
        CONFIGFILE:protractor.conf.js
      },
      跑: {}
    }


  4. 添加量角器任务测试

      grunt.registerTask(测试,[
      干净:服务器',
      并发:测试',
      自动prefixer',
      连接:测试',
      '因果报应',
      量角器:运行
    ]);


  5. 下载并启动硒服务器:

      node_modules /量角器/斌/ webdriver的经理更新
    node_modules /量角器/斌/ webdriver的经理开始

    (在Windows中:)

     节点node_modules /量角器/斌/ webdriver的经理更新
    节点node_modules /量角器/斌/ webdriver的经理开始


  6. 更​​新的package.json ,添加以下后devDependencies。这之后将运行命令 NPM安装,这样你就不需要记住每一次。

     脚本:{
      安装:节点node_modules /量角器/斌/ webdriver的经理更新
    }


  7. 使用咕噜运行测试

     咕噜测试


如果你想量角器来启动服务器给你,删除

  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?

解决方案

  1. Install protractor and grunt-protractor-runner from npm:

    npm install protractor grunt-protractor-runner --save-dev
    

  2. Create a config file for protractor (protractor.conf.js), change specs and baseUrl 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
    }
    

  3. Update your Gruntfile.js, add the following after the karma task:

    protractor: {
      options: {
        keepAlive: true,
        configFile: "protractor.conf.js"
      },
      run: {}
    }
    

  4. Add the protractor task under test

    grunt.registerTask('test', [
      'clean:server',
      'concurrent:test',
      'autoprefixer',
      'connect:test',
      'karma',
      'protractor:run'
    ]);
    

  5. 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
    

  6. Update your package.json, add the following after "devDependencies". This will run the command after npm install so you don't need to remember every time.

    "scripts": {
      "install": "node node_modules/protractor/bin/webdriver-manager update"
    }
    

  7. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆