@cuppet/core 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
- /**
2
- * @type {string}
3
- * @name scenarioName - name of the scenario from the Before hook
4
- */
5
- const { Given, When } = require('@cucumber/cucumber');
6
- const accessibilitySteps = require('../../../src/accessibilityTesting');
7
- const dataStorage = require('../../../src/dataStorage');
8
- const main = require('../../../src/mainFunctions');
9
-
10
- Given('I validate the saved page accessibility', async function () {
11
- const path = await dataStorage.getVariable('path');
12
- await accessibilitySteps.validatePageAccessibility(this.browser, this.page, this.scenarioName, path);
13
- });
14
- When('I validate the accessibility of the {string} page', async function (path) {
15
- const preparedPath = main.prepareUrl(path);
16
- await accessibilitySteps.validatePageAccessibility(this.browser, this.page, this.scenarioName, preparedPath);
17
- });
1
+ /**
2
+ * @type {string}
3
+ * @name scenarioName - name of the scenario from the Before hook
4
+ */
5
+ const { Given, When } = require('@cucumber/cucumber');
6
+ const accessibilitySteps = require('../../../src/accessibilityTesting');
7
+ const dataStorage = require('../../../src/dataStorage');
8
+ const main = require('../../../src/mainFunctions');
9
+
10
+ Given('I validate the saved page accessibility', async function () {
11
+ const path = await dataStorage.getVariable('path');
12
+ await accessibilitySteps.validatePageAccessibility(this.browser, this.page, this.scenarioName, path);
13
+ });
14
+ When('I validate the accessibility of the {string} page', async function (path) {
15
+ const preparedPath = main.prepareUrl(path);
16
+ await accessibilitySteps.validatePageAccessibility(this.browser, this.page, this.scenarioName, preparedPath);
17
+ });
@@ -1,52 +1,52 @@
1
- const { Given, When, Then } = require('@cucumber/cucumber');
2
- const apiSteps = require('../../../src/apiFunctions');
3
- const main = require('../../../src/mainFunctions');
4
- const dataStorage = require('../../../src/dataStorage');
5
-
6
- Given('that I send a {string} request to {string}', async function (method, path) {
7
- await apiSteps.sendRequest(method, path);
8
- });
9
- When(
10
- 'I send a {string} request to {string} with http header {string} and value {string}',
11
- async function (method, path, headerName, headerValue) {
12
- const name = await dataStorage.checkForSavedVariable(headerName);
13
- const value = await dataStorage.checkForSavedVariable(headerValue);
14
- const headers = {};
15
- headers[name] = value;
16
- await apiSteps.sendRequest(method, path, headers);
17
- }
18
- );
19
- Given('the response code should be {string}', async function (code) {
20
- await apiSteps.validateResponseCode(code);
21
- });
22
- Then('the response should be an {string}', async function (type) {
23
- await apiSteps.validateResponseType(type);
24
- });
25
- Then('the property {string} should be an {string}', async function (property, type) {
26
- await apiSteps.propertyIs(property, type);
27
- });
28
- Then('the response should have property {string} with value {string}', async function (property, value) {
29
- await apiSteps.propertyHasValue(property, value);
30
- });
31
- When('I store {string} to {string} variable', async function (property, variable) {
32
- await apiSteps.iRememberVariable(property, variable);
33
- });
34
- Given('that I have request body', async function (docString) {
35
- const body = JSON.stringify(docString);
36
- await apiSteps.prepareRequestBody(body);
37
- });
38
- Given(
39
- 'I put {string} to {string} property of {string} element in the body',
40
- async function (value, property, parentObj) {
41
- await apiSteps.iPutValuesInRequestBody(value, property, parentObj);
42
- }
43
- );
44
-
45
- Given('I create json object from {string} file', async function (filePath) {
46
- const checkedPath = await dataStorage.checkForSavedVariable(filePath);
47
- await apiSteps.createRequestBodyFromFile(checkedPath);
48
- });
49
- Given('I validate that the page is a valid XML', async function () {
50
- const currentPath = main.extractPath(this.page, true);
51
- await apiSteps.validateXMLEndpoint(currentPath);
52
- });
1
+ const { Given, When, Then } = require('@cucumber/cucumber');
2
+ const apiSteps = require('../../../src/apiFunctions');
3
+ const main = require('../../../src/mainFunctions');
4
+ const dataStorage = require('../../../src/dataStorage');
5
+
6
+ Given('that I send a {string} request to {string}', async function (method, path) {
7
+ await apiSteps.sendRequest(method, path);
8
+ });
9
+ When(
10
+ 'I send a {string} request to {string} with http header {string} and value {string}',
11
+ async function (method, path, headerName, headerValue) {
12
+ const name = await dataStorage.checkForSavedVariable(headerName);
13
+ const value = await dataStorage.checkForSavedVariable(headerValue);
14
+ const headers = {};
15
+ headers[name] = value;
16
+ await apiSteps.sendRequest(method, path, headers);
17
+ }
18
+ );
19
+ Given('the response code should be {string}', async function (code) {
20
+ await apiSteps.validateResponseCode(code);
21
+ });
22
+ Then('the response should be an {string}', async function (type) {
23
+ await apiSteps.validateResponseType(type);
24
+ });
25
+ Then('the property {string} should be an {string}', async function (property, type) {
26
+ await apiSteps.propertyIs(property, type);
27
+ });
28
+ Then('the response should have property {string} with value {string}', async function (property, value) {
29
+ await apiSteps.propertyHasValue(property, value);
30
+ });
31
+ When('I store {string} to {string} variable', async function (property, variable) {
32
+ await apiSteps.iRememberVariable(property, variable);
33
+ });
34
+ Given('that I have request body', async function (docString) {
35
+ const body = JSON.stringify(docString);
36
+ await apiSteps.prepareRequestBody(body);
37
+ });
38
+ Given(
39
+ 'I put {string} to {string} property of {string} element in the body',
40
+ async function (value, property, parentObj) {
41
+ await apiSteps.iPutValuesInRequestBody(value, property, parentObj);
42
+ }
43
+ );
44
+
45
+ Given('I create json object from {string} file', async function (filePath) {
46
+ const checkedPath = await dataStorage.checkForSavedVariable(filePath);
47
+ await apiSteps.createRequestBodyFromFile(checkedPath);
48
+ });
49
+ Given('I validate that the page is a valid XML', async function () {
50
+ const currentPath = main.extractPath(this.page, true);
51
+ await apiSteps.validateXMLEndpoint(currentPath);
52
+ });
@@ -1,17 +1,17 @@
1
- /**
2
- * @type {string}
3
- * @name scenarioName - name of the scenario from the Before hook
4
- */
5
- const { Given, When } = require('@cucumber/cucumber');
6
- const lighthouseMethods = require('../../../src/lighthouse');
7
- const dataStorage = require('../../../src/dataStorage');
8
- const main = require('../../../src/mainFunctions');
9
-
10
- Given('I generate lighthouse report for the saved page', async function () {
11
- const path = await dataStorage.getVariable('path');
12
- await lighthouseMethods.validatePageSpeed(this.page, path, this.scenarioName);
13
- });
14
- When('I generate lighthouse report for {string} page', async function (path) {
15
- const preparedPath = main.prepareUrl(path);
16
- await lighthouseMethods.validatePageSpeed(this.page, preparedPath, this.scenarioName);
17
- });
1
+ /**
2
+ * @type {string}
3
+ * @name scenarioName - name of the scenario from the Before hook
4
+ */
5
+ const { Given, When } = require('@cucumber/cucumber');
6
+ const lighthouseMethods = require('../../../src/lighthouse');
7
+ const dataStorage = require('../../../src/dataStorage');
8
+ const main = require('../../../src/mainFunctions');
9
+
10
+ Given('I generate lighthouse report for the saved page', async function () {
11
+ const path = await dataStorage.getVariable('path');
12
+ await lighthouseMethods.validatePageSpeed(this.page, path, this.scenarioName);
13
+ });
14
+ When('I generate lighthouse report for {string} page', async function (path) {
15
+ const preparedPath = main.prepareUrl(path);
16
+ await lighthouseMethods.validatePageSpeed(this.page, preparedPath, this.scenarioName);
17
+ });
@@ -1,26 +1,26 @@
1
- /**
2
- * @type {string}
3
- * @name scenarioName - name of the scenario from the Before hook
4
- */
5
- const { Given, Then } = require('@cucumber/cucumber');
6
- const imageCompare = require('../../../src/visualRegression');
7
- const main = require('../../../src/mainFunctions');
8
- const dataStorage = require('../../../src/dataStorage');
9
- Given('I generate reference screenshot for {string}', async function (path) {
10
- const storedUrl = await dataStorage.checkForVariable(path);
11
- const url = await main.prepareUrl(storedUrl);
12
- await imageCompare.runBackStopSingleScenario(this.scenarioName, url, 'reference');
13
- });
14
- Then('I compare {string} to reference screenshot', async function (path) {
15
- const storedUrl = await dataStorage.checkForVariable(path);
16
- const url = await main.prepareUrl(storedUrl);
17
- await imageCompare.runBackStopSingleScenario(this.scenarioName, url, 'test');
18
- });
19
- Given('I generate reference screenshot for multiple pages', async function (docString) {
20
- const pages = JSON.parse(docString);
21
- await imageCompare.runBackstopMultiplePages(pages, 'reference');
22
- });
23
- Then('I compare multiple pages to their references', async function (docString) {
24
- const pages = JSON.parse(docString);
25
- await imageCompare.runBackstopMultiplePages(pages, 'test');
26
- });
1
+ /**
2
+ * @type {string}
3
+ * @name scenarioName - name of the scenario from the Before hook
4
+ */
5
+ const { Given, Then } = require('@cucumber/cucumber');
6
+ const imageCompare = require('../../../src/visualRegression');
7
+ const main = require('../../../src/mainFunctions');
8
+ const dataStorage = require('../../../src/dataStorage');
9
+ Given('I generate reference screenshot for {string}', async function (path) {
10
+ const storedUrl = await dataStorage.checkForVariable(path);
11
+ const url = await main.prepareUrl(storedUrl);
12
+ await imageCompare.runBackStopSingleScenario(this.scenarioName, url, 'reference');
13
+ });
14
+ Then('I compare {string} to reference screenshot', async function (path) {
15
+ const storedUrl = await dataStorage.checkForVariable(path);
16
+ const url = await main.prepareUrl(storedUrl);
17
+ await imageCompare.runBackStopSingleScenario(this.scenarioName, url, 'test');
18
+ });
19
+ Given('I generate reference screenshot for multiple pages', async function (docString) {
20
+ const pages = JSON.parse(docString);
21
+ await imageCompare.runBackstopMultiplePages(pages, 'reference');
22
+ });
23
+ Then('I compare multiple pages to their references', async function (docString) {
24
+ const pages = JSON.parse(docString);
25
+ await imageCompare.runBackstopMultiplePages(pages, 'test');
26
+ });
@@ -1,4 +1,5 @@
1
1
  const { setWorldConstructor, setDefaultTimeout } = require('@cucumber/cucumber');
2
+ const commonFields = require('./commonComponents/commonFields');
2
3
 
3
4
  setDefaultTimeout(120 * 1000);
4
5
 
@@ -6,6 +7,7 @@ setDefaultTimeout(120 * 1000);
6
7
  class World {
7
8
  constructor({ attach }) {
8
9
  this.attach = attach;
10
+ this.commonFields = commonFields;
9
11
  }
10
12
 
11
13
  fixSonar() {
@@ -0,0 +1,17 @@
1
+ Feature: Open DEMO QA (as base site) and use the elements section
2
+
3
+ Scenario: Go to demo qa page and open the elements section
4
+ Given I go to "/"
5
+ And I should see "Elements" in "Cards" region
6
+ Then I click on the text "Elements" in the "Cards" region
7
+ And I wait for the text "Please select an item from left" to appear within "5" seconds
8
+ Then I click on the element "TextBox"
9
+ And I wait for "0.5" seconds
10
+ And I fill in "#userName" with "Example Name"
11
+ And I fill in "#userEmail" with "example@example.com"
12
+ And I fill in "#currentAddress" with "Example text in text area"
13
+ Then I click on the element "#submit"
14
+ And I wait for element with "#output" selector to appear within "2" seconds
15
+ And I should see the element with selector "#name"
16
+ And I should see the element with selector "#email"
17
+ And I should see the element with selector "p#currentAddress"
package/index.js CHANGED
@@ -1,43 +1,43 @@
1
- // Core Cuppet Framework Components
2
- // This package provides the core testing framework functionality
3
-
4
- // Export main function modules
5
- const elementInteraction = require('./src/elementInteraction');
6
- const dataStorage = require('./src/dataStorage');
7
- const mainFunctions = require('./src/mainFunctions');
8
- const helperFunctions = require('./src/helperFunctions');
9
- const apiFunctions = require('./src/apiFunctions');
10
- const appiumTesting = require('./src/appiumTesting');
11
- const accessibilityTesting = require('./src/accessibilityTesting');
12
- const lighthouse = require('./src/lighthouse');
13
- const visualRegression = require('./src/visualRegression');
14
-
15
- // Export managers
16
- const BrowserManager = require('./features/app/browserManager');
17
- const AppiumManager = require('./features/app/appiumManager');
18
-
19
- // Export step definitions
20
- const stepDefinitions = require('./stepDefinitions');
21
-
22
- module.exports = {
23
- // Core functions
24
- elementInteraction,
25
- dataStorage,
26
- mainFunctions,
27
- helperFunctions,
28
- apiFunctions,
29
- appiumTesting,
30
- accessibilityTesting,
31
- lighthouse,
32
- visualRegression,
33
-
34
- // Managers
35
- BrowserManager,
36
- AppiumManager,
37
-
38
- // Step definitions
39
- stepDefinitions,
40
-
41
- // Version info
42
- version: require('./package.json').version
43
- };
1
+ // Core Cuppet Framework Components
2
+ // This package provides the core testing framework functionality
3
+
4
+ // Export main function modules
5
+ const elementInteraction = require('./src/elementInteraction');
6
+ const dataStorage = require('./src/dataStorage');
7
+ const mainFunctions = require('./src/mainFunctions');
8
+ const helperFunctions = require('./src/helperFunctions');
9
+ const apiFunctions = require('./src/apiFunctions');
10
+ const appiumTesting = require('./src/appiumTesting');
11
+ const accessibilityTesting = require('./src/accessibilityTesting');
12
+ const lighthouse = require('./src/lighthouse');
13
+ const visualRegression = require('./src/visualRegression');
14
+
15
+ // Export managers
16
+ const BrowserManager = require('./features/app/browserManager');
17
+ const AppiumManager = require('./features/app/appiumManager');
18
+
19
+ // Export step definitions
20
+ const stepDefinitions = require('./stepDefinitions');
21
+
22
+ module.exports = {
23
+ // Core functions
24
+ elementInteraction,
25
+ dataStorage,
26
+ mainFunctions,
27
+ helperFunctions,
28
+ apiFunctions,
29
+ appiumTesting,
30
+ accessibilityTesting,
31
+ lighthouse,
32
+ visualRegression,
33
+
34
+ // Managers
35
+ BrowserManager,
36
+ AppiumManager,
37
+
38
+ // Step definitions
39
+ stepDefinitions,
40
+
41
+ // Version info
42
+ version: require('./package.json').version,
43
+ };
package/package.json CHANGED
@@ -1,57 +1,72 @@
1
- {
2
- "name": "@cuppet/core",
3
- "version": "1.0.0",
4
- "description": "Core testing framework components for Cuppet - BDD framework based on Cucumber and Puppeteer",
5
- "main": "index.js",
6
- "files": [
7
- "src/",
8
- "features/",
9
- "index.js",
10
- "stepDefinitions.js"
11
- ],
12
- "keywords": [
13
- "testing",
14
- "bdd",
15
- "cucumber",
16
- "puppeteer",
17
- "appium",
18
- "automation",
19
- "e2e"
20
- ],
21
- "author": "Miroslav Rusev",
22
- "license": "ISC",
23
- "peerDependencies": {
24
- "@cucumber/cucumber": "^11.0.0",
25
- "puppeteer": "^24.0.1",
26
- "config": "^3.3.9"
27
- },
28
- "dependencies": {
29
- "@supercharge/strings": "^2.0.0",
30
- "axios": "^1.8.2",
31
- "backstopjs": "^6.3.23",
32
- "chai": "^4.3.7",
33
- "lighthouse": "^12.1.0",
34
- "mime": "^3.0.0",
35
- "moment": "^2.30.1",
36
- "pa11y": "^8.0.0",
37
- "pa11y-reporter-html": "^2.0.0",
38
- "xml2js": "^0.6.2"
39
- },
40
- "devDependencies": {
41
- "@wdio/globals": "^9.14.0",
42
- "appium": "^2.18.0",
43
- "appium-uiautomator2-driver": "^4.2.3",
44
- "webdriverio": "9.12.7"
45
- },
46
- "scripts": {
47
- "test": "echo \"Error: no test specified\" && exit 1"
48
- },
49
- "repository": {
50
- "type": "git",
51
- "url": "git+https://github.com/MiroslavRusev/cuppet-core.git"
52
- },
53
- "bugs": {
54
- "url": "https://github.com/MiroslavRusev/cuppet-core/issues"
55
- },
56
- "homepage": "https://github.com/MiroslavRusev/cuppet-core#readme"
57
- }
1
+ {
2
+ "name": "@cuppet/core",
3
+ "version": "1.0.1",
4
+ "description": "Core testing framework components for Cuppet - BDD framework based on Cucumber and Puppeteer",
5
+ "main": "index.js",
6
+ "files": [
7
+ "src/",
8
+ "features/",
9
+ "index.js",
10
+ "stepDefinitions.js"
11
+ ],
12
+ "keywords": [
13
+ "testing",
14
+ "bdd",
15
+ "cucumber",
16
+ "puppeteer",
17
+ "appium",
18
+ "automation",
19
+ "e2e"
20
+ ],
21
+ "author": "Miroslav Rusev",
22
+ "license": "ISC",
23
+ "peerDependencies": {
24
+ "@cucumber/cucumber": "^11.0.0",
25
+ "config": "^3.3.9",
26
+ "puppeteer": "^24.0.1"
27
+ },
28
+ "dependencies": {
29
+ "@supercharge/strings": "^2.0.0",
30
+ "axios": "^1.8.2",
31
+ "backstopjs": "^6.3.23",
32
+ "chai": "^4.3.7",
33
+ "lighthouse": "^12.1.0",
34
+ "mime": "^3.0.0",
35
+ "moment": "^2.30.1",
36
+ "pa11y": "^8.0.0",
37
+ "pa11y-reporter-html": "^2.0.0",
38
+ "xml2js": "^0.6.2"
39
+ },
40
+ "devDependencies": {
41
+ "@cucumber/cucumber": "^11.0.0",
42
+ "@semantic-release/changelog": "^6.0.3",
43
+ "@semantic-release/git": "^10.0.1",
44
+ "@semantic-release/github": "^11.0.3",
45
+ "@semantic-release/npm": "^12.0.1",
46
+ "@wdio/globals": "^9.14.0",
47
+ "appium": "^2.18.0",
48
+ "appium-uiautomator2-driver": "^4.2.3",
49
+ "config": "^3.3.9",
50
+ "eslint": "^9.29.0",
51
+ "eslint-config-prettier": "^10.1.5",
52
+ "eslint-plugin-prettier": "^5.5.1",
53
+ "prettier": "^3.6.1",
54
+ "puppeteer": "^24.0.1",
55
+ "semantic-release": "^24.2.5",
56
+ "webdriverio": "9.12.7"
57
+ },
58
+ "scripts": {
59
+ "test": "cucumber-js features/tests",
60
+ "postinstall": "sh postinstall.sh",
61
+ "lint": "eslint .",
62
+ "format": "prettier --write ."
63
+ },
64
+ "repository": {
65
+ "type": "git",
66
+ "url": "git+https://github.com/MiroslavRusev/cuppet-core.git"
67
+ },
68
+ "bugs": {
69
+ "url": "https://github.com/MiroslavRusev/cuppet-core/issues"
70
+ },
71
+ "homepage": "https://github.com/MiroslavRusev/cuppet-core#readme"
72
+ }
@@ -1,44 +1,44 @@
1
- /**
2
- * @module accessibilityTesting
3
- * @typedef {import('puppeteer').Page} Page
4
- * @typedef {import('puppeteer').Browser} Browser
5
- */
6
- const config = require('config');
7
- const storage = require('./dataStorage');
8
- const helper = require('./helperFunctions');
9
- const pa11y = require('pa11y');
10
- const htmlReporter = require('pa11y-reporter-html');
11
-
12
- module.exports = {
13
- /**
14
- * Method to validate if certain path meets the criteria from the config.
15
- * Please use the config json files to set options.
16
- * You can find more info at - https://github.com/pa11y/pa11y#configuration
17
- * @param {Browser} browser - puppeteer browser object
18
- * @param {Page} page - puppeteer page object
19
- * @param scenarioName - the current scenario name
20
- * @param path - the path of the page which accessibility will be tested
21
- * @throws Error
22
- * @returns {Promise<void>}
23
- */
24
- validatePageAccessibility: async function (browser, page, scenarioName, path) {
25
- const pa11yConfig = config.get('pa11yConfig');
26
- const configOptions = {
27
- ...pa11yConfig,
28
- browser: browser,
29
- page: page,
30
- };
31
- if (!path.startsWith('http')) {
32
- throw new Error('Only absolute paths are allowed!');
33
- }
34
-
35
- const results = await pa11y(path, configOptions);
36
- const fileName = await helper.prepareFileNameFromUrl(path);
37
- // make the URL ready for filepath usage
38
- if (results.issues) {
39
- const html = await htmlReporter.results(results);
40
- await storage.createHtmlReport('Pa11y-' + scenarioName.slice(0, -1) + fileName, html);
41
- throw new Error(`${path} page has accessibility issues. HTML report has been generated!`);
42
- }
43
- },
44
- };
1
+ /**
2
+ * @module accessibilityTesting
3
+ * @typedef {import('puppeteer').Page} Page
4
+ * @typedef {import('puppeteer').Browser} Browser
5
+ */
6
+ const config = require('config');
7
+ const storage = require('./dataStorage');
8
+ const helper = require('./helperFunctions');
9
+ const pa11y = require('pa11y');
10
+ const htmlReporter = require('pa11y-reporter-html');
11
+
12
+ module.exports = {
13
+ /**
14
+ * Method to validate if certain path meets the criteria from the config.
15
+ * Please use the config json files to set options.
16
+ * You can find more info at - https://github.com/pa11y/pa11y#configuration
17
+ * @param {Browser} browser - puppeteer browser object
18
+ * @param {Page} page - puppeteer page object
19
+ * @param scenarioName - the current scenario name
20
+ * @param path - the path of the page which accessibility will be tested
21
+ * @throws Error
22
+ * @returns {Promise<void>}
23
+ */
24
+ validatePageAccessibility: async function (browser, page, scenarioName, path) {
25
+ const pa11yConfig = config.get('pa11yConfig');
26
+ const configOptions = {
27
+ ...pa11yConfig,
28
+ browser: browser,
29
+ page: page,
30
+ };
31
+ if (!path.startsWith('http')) {
32
+ throw new Error('Only absolute paths are allowed!');
33
+ }
34
+
35
+ const results = await pa11y(path, configOptions);
36
+ const fileName = await helper.prepareFileNameFromUrl(path);
37
+ // make the URL ready for filepath usage
38
+ if (results.issues) {
39
+ const html = await htmlReporter.results(results);
40
+ await storage.createHtmlReport('Pa11y-' + scenarioName.slice(0, -1) + fileName, html);
41
+ throw new Error(`${path} page has accessibility issues. HTML report has been generated!`);
42
+ }
43
+ },
44
+ };