How to configure Protractor to use Cucumber

后端 未结 4 1560
别那么骄傲
别那么骄傲 2021-02-20 03:30

As of 0.20.1 Cucumber is now fully supported in Protractor but I\'m battling to find any documentation on how to configure it properly. Any idea how you would setup world.js?

4条回答
  •  醉话见心
    2021-02-20 04:25

    I've gotten good milage from this setup

      class ChtWorld
        chai = require('chai');
        chaiAsPromised = require('chai-as-promised');
    
        constructor:  ->
          @browser = @protractor = require('protractor').getInstance()
          @By = @protractor.By
          chai.use(chaiAsPromised)
          @expect= chai.expect
    
    
      module.exports= ->
        this.World= (callback) ->
          w = new ChtWorld()
          callback(w)
    

    Since protractor is already setup, just getting a reference to it is sufficient (note that for Cucumber to correctly load up the new world, the modules.exports has to be just right).

    As a side note, this is located in features/support/world.coffee, and not explicitly added to the 'requires' list (trying to do that got me into Gherkin Lexing error problems).

提交回复
热议问题