UNPKG

1.19 kBJavaScriptView Raw
1const { serenity } = require('@serenity-js/core');
2const { Path } = require('@serenity-js/core/lib/io');
3const {
4 ProtractorFrameworkAdapter,
5 TestRunnerDetector,
6 TestRunnerLoader
7} = require('@serenity-js/protractor/lib/adapter');
8
9/**
10 * Execute the Runner's test cases through Cucumber.
11 *
12 * @param {Runner} runner The current Protractor Runner.
13 * @param {string[]} specs Array of Directory Path Strings.
14 * @return {Promise<void>>} Promise resolved with the test results
15 */
16exports.run = function (runner, specs) {
17 return new ProtractorFrameworkAdapter(
18 serenity,
19 runner,
20 new TestRunnerDetector(new TestRunnerLoader(
21 testModeOrDefaultCwd(runner.getConfig().configDir),
22 process.pid
23 ))
24 ).run(specs);
25}
26
27function testModeOrDefaultCwd(defaulValue) {
28 if (! process.env.MULTIDEP_CUCUMBER_CONF) {
29 return Path.from(defaulValue);
30 }
31
32 // protractor-framework-adapter running in self-test mode
33 const cucumberConf = JSON.parse(process.env.MULTIDEP_CUCUMBER_CONF);
34 return Path.from(
35 __dirname,
36 `test/multidep_modules/${ cucumberConf.module }-${ cucumberConf.version }`
37 );
38}