量角器配置文件使用茉莉和黄瓜规格

时间:2017-07-05 15:08:54

标签: jasmine protractor cucumber

我使用茉莉和使用chai和黄瓜编写的行为驱动测试编写了端到端测试。我有两个配置文件来运行这些测试。如何使用单个量角器配置文件来运行茉莉和黄瓜的规格?

//cucumber.conf.js
exports.config = {
  framework: 'custom', 
  frameworkPath: require.resolve('protractor-cucumber-framework'), 
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['test/e2e/cucumber/*.feature'],
  capabilities: {
    'browserName': 'firefox',

},
baseUrl: '',

  cucumberOpts: {
    require: ['test/e2e/cucumber/*.steps.js'],  
    tags: [],                      
    strict: true,                  
    format: ["pretty"],            
    dryRun: false,                 
    compiler: []                   
  }

  //e2e.conf.js
  exports.config = {
      framework: 'jasmine2',    
    seleniumAddress: 'http://localhost:4444/wd/hub',

      specs: ['test/e2e/e2e-spec.js'],
      capabilities: {
        'browserName': 'firefox', 
    },
    baseUrl: '',
      jasmineNodeOpts: {
       showColors: true,
     }

1 个答案:

答案 0 :(得分:1)

在基本设置中,您无法提供示例框架,并且您无法在1个默认配置文件中拥有2个框架。

您可以使用命令行参数和像yargs这样的cli工具,并执行类似的操作。如果你通过例如npm script运行量角器,你可以做这样的事情

npm run e2e -- --bdd



// the commmand line tool
const argv = require('yargs').argv;

// place you default config here, that should hold all the configs that are used with 
// Jsasmine and CucumberJS
const config = {
  baseUrl: '',
  capabilities: {
    'browserName': 'firefox',

  },
  seleniumAddress: 'http://localhost:4444/wd/hub'
};

// If you pass --bdd to your commandline it will use cucumberjs, default is jasmine 2
if (argv.bdd) {
  config.framework = 'custom';
  config.frameworkPath = require.resolve('protractor-cucumber-framework');
  config.specs = ['test/e2e/cucumber/*.feature'];
  config.cucumberOpts = {
    require: ['test/e2e/cucumber/*.steps.js'],
    tags: [],
    strict: true,
    format: ["pretty"],
    dryRun: false,
    compiler: []
  };
} else {
  config.framework = 'jasmine2';
  config.specs = ['test/e2e/e2e-spec.js'];
  config.jasmineNodeOpts = {
    showColors: true,
  };
}

exports.config = config;