2017-07-05 3 views
0

Ich habe End-to-End-Tests geschrieben mit Jasmin und verhaltensgetriebenen Tests geschrieben mit Chai und Gurke. Ich habe zwei Konfigurationsdateien, um diese Tests auszuführen. Wie kann ich die Konfigurationsdatei des einzelnen Winkelmessers benutzen, um Spezifikationen von Jasmin und Gurke auszuführen?Winkelmesserkonfigurationsdatei, um beide Jasmin- und Gurkenspezifikationen zu verwenden

//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, 
    } 

Antwort

1

In einer Basis-Setup können Sie nicht, weil Sie den Rahmen zum Beispiel zur Verfügung stellen müssen, und Sie können in 2-Frameworks haben 1 Standard Konfigurationsdatei nicht.

Sie können ein Befehlszeilenargument und ein CLI-Tool wie yargs verwenden und so etwas tun. Wenn Sie Winkelmesser durch zum Beispiel ein npm script laufen können Sie so etwas wie dieses

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

Ok Dank viel tun. Ich werde diese Lösung versuchen. – Mythri

Verwandte Themen