@cuppet/core 2.0.5 → 3.0.0
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.
- package/README.md +0 -2
- package/features/app/stepDefinitions/apiSteps.js +3 -0
- package/index.js +0 -2
- package/package.json +2 -5
- package/src/apiFunctions.js +10 -1
- package/stepDefinitions.js +1 -1
- package/backStopData/backStopConfig.json +0 -32
- package/features/app/stepDefinitions/visualRegressionSteps.js +0 -26
- package/features/tests/example-visual-test.feature +0 -5
- package/src/visualRegression.js +0 -68
package/README.md
CHANGED
|
@@ -34,7 +34,6 @@ yarn test
|
|
|
34
34
|
- `appiumTesting` - Appium mobile testing
|
|
35
35
|
- `accessibilityTesting` - Accessibility testing with Pa11y
|
|
36
36
|
- `lighthouse` - Performance testing with Lighthouse
|
|
37
|
-
- `visualRegression` - Visual regression testing with BackstopJS
|
|
38
37
|
|
|
39
38
|
### Managers
|
|
40
39
|
|
|
@@ -115,7 +114,6 @@ Given('I am logged in as {string}', async function (userName) {
|
|
|
115
114
|
- `pageElements` - Page element testing
|
|
116
115
|
- `pageElementsConfig` - Page element testing with values from config
|
|
117
116
|
- `pageElementsJson` - Page element testing with values from locally stored JSON file
|
|
118
|
-
- `visualRegressionSteps` - Visual regression testing steps
|
|
119
117
|
|
|
120
118
|
## Project-Specific Components
|
|
121
119
|
|
|
@@ -22,6 +22,9 @@ Given('the response code should be {string}', async function (code) {
|
|
|
22
22
|
Then('the response should be an {string}', async function (type) {
|
|
23
23
|
await apiSteps.validateResponseType(type);
|
|
24
24
|
});
|
|
25
|
+
Then('the response should be an empty array', async function () {
|
|
26
|
+
await apiSteps.validateResponseIsEmptyArray();
|
|
27
|
+
});
|
|
25
28
|
Then('the property {string} should be an {string}', async function (property, type) {
|
|
26
29
|
await apiSteps.propertyIs(property, type);
|
|
27
30
|
});
|
package/index.js
CHANGED
|
@@ -11,7 +11,6 @@ const mqttFunctions = require('./src/mqttFunctions');
|
|
|
11
11
|
const appiumTesting = require('./src/appiumTesting');
|
|
12
12
|
const accessibilityTesting = require('./src/accessibilityTesting');
|
|
13
13
|
const lighthouse = require('./src/lighthouse');
|
|
14
|
-
const visualRegression = require('./src/visualRegression');
|
|
15
14
|
const kafkaFunctions = require('./src/kafkaFunctions');
|
|
16
15
|
|
|
17
16
|
// Export managers
|
|
@@ -32,7 +31,6 @@ module.exports = {
|
|
|
32
31
|
appiumTesting,
|
|
33
32
|
accessibilityTesting,
|
|
34
33
|
lighthouse,
|
|
35
|
-
visualRegression,
|
|
36
34
|
|
|
37
35
|
// Managers
|
|
38
36
|
BrowserManager,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuppet/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Core testing framework components for Cuppet - BDD framework based on Cucumber and Puppeteer",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"features/",
|
|
9
9
|
"index.js",
|
|
10
10
|
"stepDefinitions.js",
|
|
11
|
-
"postinstall.js"
|
|
12
|
-
"backStopData/"
|
|
11
|
+
"postinstall.js"
|
|
13
12
|
],
|
|
14
13
|
"keywords": [
|
|
15
14
|
"testing",
|
|
@@ -34,7 +33,6 @@
|
|
|
34
33
|
"appium": "3.2.2",
|
|
35
34
|
"appium-uiautomator2-driver": "7.0.0",
|
|
36
35
|
"axios": "^1.13.6",
|
|
37
|
-
"backstopjs": "^6.3.25",
|
|
38
36
|
"chai": "6.2.2",
|
|
39
37
|
"kafkajs": "^2.2.4",
|
|
40
38
|
"lighthouse": "^13.0.3",
|
|
@@ -62,7 +60,6 @@
|
|
|
62
60
|
"scripts": {
|
|
63
61
|
"test": "cucumber-js features/tests/example.feature",
|
|
64
62
|
"run:kafka": "cucumber-js features/tests/example-kafka.feature",
|
|
65
|
-
"run:visual": "cucumber-js features/tests/example-visual-test.feature",
|
|
66
63
|
"run:pa11y": "cucumber-js features/tests/example-pa11y.feature",
|
|
67
64
|
"run:lighthouse": "cucumber-js features/tests/example-lighthouse.feature",
|
|
68
65
|
"run:mqtt": "cucumber-js features/tests/example-mqtt.feature",
|
package/src/apiFunctions.js
CHANGED
|
@@ -196,7 +196,16 @@ module.exports = {
|
|
|
196
196
|
* @returns {Promise<void>}
|
|
197
197
|
*/
|
|
198
198
|
validateResponseType: async function (type) {
|
|
199
|
-
|
|
199
|
+
assert.typeOf(this.response.data, type, `Response is not an ${type}`);
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Validate that the response body is an empty array
|
|
204
|
+
* @returns {Promise<void>}
|
|
205
|
+
*/
|
|
206
|
+
validateResponseIsEmptyArray: async function () {
|
|
207
|
+
assert.isArray(this.response.data, 'Response is not an array');
|
|
208
|
+
assert.isEmpty(this.response.data, `Expected an empty array but got ${JSON.stringify(this.response.data)}`);
|
|
200
209
|
},
|
|
201
210
|
|
|
202
211
|
/**
|
package/stepDefinitions.js
CHANGED
|
@@ -14,5 +14,5 @@ module.exports = {
|
|
|
14
14
|
pageElements: require('./features/app/stepDefinitions/pageElements'),
|
|
15
15
|
pageElementsConfig: require('./features/app/stepDefinitions/pageElementsConfig'),
|
|
16
16
|
pageElementsJson: require('./features/app/stepDefinitions/pageElementsJson'),
|
|
17
|
-
|
|
17
|
+
kafkaSteps: require('./features/app/stepDefinitions/kafkaSteps'),
|
|
18
18
|
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "test",
|
|
3
|
-
"viewports": [
|
|
4
|
-
{
|
|
5
|
-
"label": "desktop",
|
|
6
|
-
"width": 1920,
|
|
7
|
-
"height": 1080
|
|
8
|
-
}
|
|
9
|
-
],
|
|
10
|
-
"scenarios": [
|
|
11
|
-
{
|
|
12
|
-
"label": "Single Test",
|
|
13
|
-
"url": "https://example.com"
|
|
14
|
-
}
|
|
15
|
-
],
|
|
16
|
-
"paths": {
|
|
17
|
-
"bitmaps_reference": "backStopData/bitmaps_reference",
|
|
18
|
-
"bitmaps_test": "backStopData/bitmaps_test",
|
|
19
|
-
"engine_scripts": "backStopData/engine_scripts",
|
|
20
|
-
"html_report": "backStopData/html_report",
|
|
21
|
-
"ci_report": "backStopData/ci_report"
|
|
22
|
-
},
|
|
23
|
-
"report": ["CI"],
|
|
24
|
-
"engine": "puppeteer",
|
|
25
|
-
"engineOptions": {
|
|
26
|
-
"args": ["--headless=new"]
|
|
27
|
-
},
|
|
28
|
-
"asyncCaptureLimit": 5,
|
|
29
|
-
"asyncCompareLimit": 50,
|
|
30
|
-
"debug": false,
|
|
31
|
-
"debugWindow": false
|
|
32
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
});
|
package/src/visualRegression.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
const config = require('config');
|
|
2
|
-
const backStop = require('backstopjs');
|
|
3
|
-
const backStopConfig = require('../backStopData/backStopConfig.json');
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @returns {Object} - the backstop configuration object
|
|
9
|
-
*/
|
|
10
|
-
backstopConfigPrepare: function () {
|
|
11
|
-
let newConfig = backStopConfig;
|
|
12
|
-
newConfig.id = process.env.NODE_CONFIG_ENV || 'default';
|
|
13
|
-
const browserViewport = config.get('browserOptions.viewport.backstop');
|
|
14
|
-
newConfig.viewports[0].width = Number(browserViewport.width);
|
|
15
|
-
newConfig.viewports[0].height = Number(browserViewport.height);
|
|
16
|
-
newConfig.engineOptions.args = config.get('browserOptions.args');
|
|
17
|
-
return newConfig;
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @param command
|
|
23
|
-
* @param configObject
|
|
24
|
-
* @returns {Promise<void>}
|
|
25
|
-
*/
|
|
26
|
-
runBackStop: async function (command, configObject) {
|
|
27
|
-
await backStop(command, { config: configObject })
|
|
28
|
-
.then(() => {
|
|
29
|
-
console.log(`${command} backstop run executed successfully!`);
|
|
30
|
-
// test successful
|
|
31
|
-
})
|
|
32
|
-
.catch((error) => {
|
|
33
|
-
throw new Error(error);
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
* @param scenarioName
|
|
40
|
-
* @param path
|
|
41
|
-
* @param testCommand
|
|
42
|
-
* @returns {Promise<void>}
|
|
43
|
-
*/
|
|
44
|
-
runBackStopSingleScenario: async function (scenarioName, path, testCommand) {
|
|
45
|
-
const newConfig = this.backstopConfigPrepare();
|
|
46
|
-
newConfig.scenarios[0].label = scenarioName;
|
|
47
|
-
newConfig.scenarios[0].url = path;
|
|
48
|
-
await this.runBackStop(testCommand, newConfig);
|
|
49
|
-
},
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
* @param pages
|
|
53
|
-
* @param testCommand
|
|
54
|
-
* @returns {Promise<void>}
|
|
55
|
-
*/
|
|
56
|
-
runBackstopMultiplePages: async function (pages, testCommand) {
|
|
57
|
-
const newConfig = this.backstopConfigPrepare();
|
|
58
|
-
newConfig.scenarios = [];
|
|
59
|
-
pages.forEach((page) => {
|
|
60
|
-
newConfig.scenarios.push({
|
|
61
|
-
label: page.label,
|
|
62
|
-
url: page.url,
|
|
63
|
-
// Add other scenario properties as needed...
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
await this.runBackStop(testCommand, newConfig);
|
|
67
|
-
},
|
|
68
|
-
};
|