Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions features/step-definitions/google-search-steps.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
module.exports = function () {
/* eslint new-cap: "off" */
const { Given, When, Then, setWorldConstructor } = require('@cucumber/cucumber');
const CustomWorld = require('../../runtime/world');

this.Given(/^I am online at "([^"]*)"/, function (url) {
return helpers.openPage(url);
});
setWorldConstructor(CustomWorld);
CustomWorld.setup();

this.When(/^I search Google for "([^"]*)"$/, function (searchQuery) {
Given(/^I am online at "([^"]*)"/, function (url) {
throw new Error('abcdef')
return helpers.openPage(url);
});

// execute ./page-objects/google-search.js preformSearch method
return pageObjects.googleSearch.preformSearch(searchQuery);
});
When(/^I search Google for "([^"]*)"$/, function (searchQuery) {

this.Then(/^I should see "([^"]*)" in the results$/, function (keywords) {
// execute ./page-objects/google-search.js preformSearch method
return pageObjects.googleSearch.preformSearch(searchQuery);
});

// resolves if an item on the page contains text
return helpers.waitForLinkText(keywords, false, 30);
});
Then(/^I should see "([^"]*)" in the results$/, function (keywords) {

this.Then(/^I should go back one page$/, function () {
return page.goBack();
});
};
// resolves if an item on the page contains text
return helpers.waitForLinkText(keywords, false, 30);
});

Then(/^I should go back one page$/, function () {
return page.goBack();
});
34 changes: 19 additions & 15 deletions features/step-definitions/orca-scan-demo-steps.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
module.exports = function () {
/* eslint new-cap: "off" */
const { Given, When, Then, setWorldConstructor } = require('@cucumber/cucumber');
const CustomWorld = require('../../runtime/world');

this.Given(/^I am on the Orca Scan barcode tracking website/, function() {
return helpers.loadPage(pageObjects.orcaScan.url);
});
setWorldConstructor(CustomWorld);
CustomWorld.setup();

this.When(/^I click the Book a demo button$/, async function () {
Given(/^I am on the Orca Scan barcode tracking website/, function() {
return helpers.loadPage(this.page, pageObjects.orcaScan.url);
});

// click the book a demo button
await page.click(pageObjects.orcaScan.selectors.bookADemoButton);
When(/^I click the Book a demo button$/, async function () {

// wait for calendly iframe to appear
await page.waitForSelector(pageObjects.orcaScan.selectors.calendlyIFrame);
});
// click the book a demo button
await this.page.click(pageObjects.orcaScan.selectors.bookADemoButton);

this.Then(/^I should be able to book a demo$/, function () {
// wait for calendly iframe to appear
await this.page.waitForSelector(pageObjects.orcaScan.selectors.calendlyIFrame);
});

// check the calendly booking frame appears
return page.$(pageObjects.orcaScan.selectors.calendlyIFrame);
});
};
Then(/^I should be able to book a demo$/, function () {

// check the calendly booking frame appears
return this.page.$(pageObjects.orcaScan.selectors.calendlyIFrame);
});
42 changes: 24 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var fs = require('fs-plus');
var path = require('path');
var program = require('commander');
var pjson = require('./package.json');
var cucumber = require('cucumber');
var cucumber = require('@cucumber/cucumber');
var chalk = require('chalk');
var helpers = require('./runtime/helpers.js');
var merge = require('merge');
Expand Down Expand Up @@ -39,6 +39,7 @@ global.disableLaunchReport = false;
global.noScreenshot = false;
global.slowMo = config.slowMo;

const argVParams = [... process.argv];
program
.version(pjson.version)
.description(pjson.description)
Expand All @@ -58,7 +59,7 @@ program
.option('--slowMo <number>', 'specified amount of milliseconds to slow down Puppeteer operations by. Defaults to ' + config.slowMo)
.option('--networkSpeed <name>', 'simulate connection speeds, options are: gprs, 2g, 3g, 4g, dsl, wifi. Defaults is unset (full speed)')
.option('--updateBaselineImage', 'automatically update the baseline image after a failed comparison')
.parse(process.argv);
.parse(argVParams);

program.on('--help', function () {
console.log(' For more details please visit https://github.com/orca-scan/puppeteer-cucumber-js#readme\n');
Expand Down Expand Up @@ -165,33 +166,33 @@ if (fs.existsSync(sharedObjectsPath)) {
global.helpers = helpers;

// rewrite command line switches for cucumber
process.argv.splice(2, 100);
argVParams.splice(2, 100);

// allow specific feature files to be executed
if (program.featureFiles) {
var splitFeatureFiles = program.featureFiles.split(',');

splitFeatureFiles.forEach(function (feature) {
process.argv.push(feature);
argVParams.push(feature);
});
}

// add switch to tell cucumber to produce json report files
process.argv.push('-f');
process.argv.push('pretty');
process.argv.push('-f');
// process.argv.push('pretty');
// process.argv.push('-f');
process.argv.push('json:' + path.resolve(__dirname, global.reportsPath, 'cucumber-report.json'));

// add cucumber world as first required script (this sets up the globals)
process.argv.push('-r');
process.argv.push(path.resolve(__dirname, 'runtime/world.js'));
argVParams.push('--require');
argVParams.push(path.resolve(__dirname, 'runtime/world.js'));

// add path to import step definitions
process.argv.push('-r');
process.argv.push(path.resolve(config.steps));
argVParams.push('--require');
argVParams.push(path.resolve(config.steps));

if (program.failFast) {
process.argv.push('--fail-fast');
argVParams.push('--fail-fast');
}

// add tag(s)
Expand All @@ -217,26 +218,31 @@ if (program.tags) {
});

program.tags.forEach(function (tag) {
process.argv.push('-t');
process.argv.push(tag);
argVParams.push('-t');
argVParams.push(tag);
});
}

if (program.worldParameters) {
process.argv.push('--world-parameters');
process.argv.push(program.worldParameters);
argVParams.push('--world-parameters');
argVParams.push(program.worldParameters);
}

// add strict option (fail if there are any undefined or pending steps)
process.argv.push('-S');
// process.argv.push('-S');

// // abort the run on first failure
// process.argv.push('--fail-fast');

//
// execute cucumber
//
var cucumberCli = new cucumber.Cli(process.argv);
const cliConfig = {
argv: argVParams,
cwd: process.cwd(),
stdout: process.stdout
};
var cucumberCli = new cucumber.Cli(cliConfig);

global.cucumber = cucumber;

Expand Down Expand Up @@ -335,4 +341,4 @@ function getFeaturesFileTags() {
});

return result;
}
}
Loading