2017-07-05 72 views
0

我有端到端测试使用茉莉和行为驱动的测试编写使用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

在你可以因为你不需要提供例如框架,你不能有1 默认配置文件2个框架基本建立。

你可以做的是使用一个命令行参数和一个cli工具,如yargs,并做这样的事情。如果通过例如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;

+0

好感谢了很多。我会尝试这个解决方案。 – Mythri