@enact/ui-test-utils 0.7.0 → 0.7.2
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/.travis.yml +6 -2
- package/package.json +11 -11
- package/screenshot/utils/confHelpers.js +17 -23
- package/screenshot/wdio.conf.js +6 -7
- package/ui/wdio.docker.conf.js +1 -1
- package/utils/runTest.js +18 -5
package/.travis.yml
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
dist: focal
|
|
1
2
|
language: node_js
|
|
2
3
|
node_js:
|
|
3
|
-
- "
|
|
4
|
+
- "18"
|
|
5
|
+
before_install:
|
|
6
|
+
- sudo apt-get update
|
|
7
|
+
- sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
|
|
4
8
|
install:
|
|
5
9
|
- npm install
|
|
6
10
|
script:
|
|
7
11
|
- echo -e "\x1b\x5b35;1m*** Linting...\x1b\x5b0m"
|
|
8
|
-
- npm run lint
|
|
12
|
+
- npm run lint -- --report-unused-disable-directives --max-warnings 0
|
|
9
13
|
- echo -e "\x1b\x5b35;1m*** Linting complete...\x1b\x5b0m"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/ui-test-utils",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "UI Testing for the Enact framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@wdio/cli": "
|
|
20
|
-
"@wdio/dot-reporter": "
|
|
21
|
-
"@wdio/local-runner": "
|
|
22
|
-
"@wdio/mocha-framework": "
|
|
23
|
-
"@wdio/selenium-standalone-service": "
|
|
24
|
-
"@wdio/spec-reporter": "
|
|
25
|
-
"@wdio/static-server-service": "
|
|
26
|
-
"@wdio/sync": "
|
|
19
|
+
"@wdio/cli": "7.12.4",
|
|
20
|
+
"@wdio/dot-reporter": "7.10.1",
|
|
21
|
+
"@wdio/local-runner": "7.12.4",
|
|
22
|
+
"@wdio/mocha-framework": "7.12.4",
|
|
23
|
+
"@wdio/selenium-standalone-service": "7.10.1",
|
|
24
|
+
"@wdio/spec-reporter": "7.10.1",
|
|
25
|
+
"@wdio/static-server-service": "7.10.1",
|
|
26
|
+
"@wdio/sync": "7.12.4",
|
|
27
27
|
"chai": "4.3.4",
|
|
28
28
|
"chalk": "^4.1.2",
|
|
29
29
|
"cross-spawn": "^7.0.3",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"ramda": "^0.27.1",
|
|
36
36
|
"readdirp": "^3.6.0",
|
|
37
37
|
"wdio-docker-service": "^3.1.2",
|
|
38
|
-
"wdio-
|
|
39
|
-
"webdriverio": "
|
|
38
|
+
"wdio-image-comparison-service": "^3.0.0",
|
|
39
|
+
"webdriverio": "7.12.4"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"babel-eslint": "^10.1.0",
|
|
@@ -2,7 +2,6 @@ const crypto = require('crypto'),
|
|
|
2
2
|
path = require('path'),
|
|
3
3
|
fs = require('fs');
|
|
4
4
|
|
|
5
|
-
const VisualRegressionCompare = require('wdio-novus-visual-regression-service/compare');
|
|
6
5
|
const buildApps = require('../../src/build-apps');
|
|
7
6
|
const makeHeader = require('./headerTemplate');
|
|
8
7
|
|
|
@@ -23,21 +22,18 @@ function getScreenshotName (basePath) {
|
|
|
23
22
|
|
|
24
23
|
// shorten the name with a little bit of leading context to help find the file manually if necessary
|
|
25
24
|
testName = testName.substring(0, 128) + '-' + crypto.createHash('md5').update(testName).digest('hex');
|
|
26
|
-
|
|
27
|
-
return
|
|
25
|
+
let screenshotFileName = path.join(basePath, ...testNameParts, `${testName}.png`);
|
|
26
|
+
return screenshotFileName.replace(/ /g, '_');
|
|
28
27
|
};
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const distPath = path.join(process.cwd(), 'tests', 'screenshot', 'dist');
|
|
31
|
+
const baselineRelativePath = 'screenshots/reference';
|
|
32
|
+
const screenshotRelativePath = 'screenshots/screen';
|
|
33
|
+
const baselineFolder = path.join(distPath, baselineRelativePath);
|
|
34
|
+
const screenshotFolder = path.join(distPath, screenshotRelativePath);
|
|
34
35
|
|
|
35
|
-
const
|
|
36
|
-
referenceName: generateReferenceName,
|
|
37
|
-
screenshotName: generateScreenshotName,
|
|
38
|
-
diffName: generateDiffName,
|
|
39
|
-
misMatchTolerance: 0.005
|
|
40
|
-
});
|
|
36
|
+
const generateReferenceName = getScreenshotName(baselineFolder);
|
|
41
37
|
|
|
42
38
|
function initFile (name, content) {
|
|
43
39
|
const dir = path.dirname(name);
|
|
@@ -77,16 +73,16 @@ function beforeTest (testData) {
|
|
|
77
73
|
function afterTest (testData, _context, {passed}) {
|
|
78
74
|
// If this doesn't include context data, not a screenshot test
|
|
79
75
|
if (testData && testData.title && testData.context && testData.context.params) {
|
|
76
|
+
const fileName = testData.context.fileName.replace(/ /g, '_') + '.png';
|
|
77
|
+
const referencePath = path.join(baselineRelativePath, fileName);
|
|
78
|
+
|
|
80
79
|
if (_context.isNewScreenshot) {
|
|
81
|
-
const filename = generateReferenceName({test: testData});
|
|
82
80
|
fs.open(newScreenshotFilename, 'a', (err, fd) => {
|
|
83
|
-
const distPath = path.join(process.cwd(), 'tests', 'screenshot', 'dist'),
|
|
84
|
-
relativeName = path.relative(distPath, filename);
|
|
85
81
|
if (err) {
|
|
86
82
|
console.error('Unable to create log file!');
|
|
87
83
|
} else {
|
|
88
84
|
const {params, url} = testData.context;
|
|
89
|
-
const output = {title: testData.title.replace(/~\//g, '/'), path:
|
|
85
|
+
const output = {title: testData.title.replace(/~\//g, '/'), path: referencePath, params, url};
|
|
90
86
|
fs.appendFile(fd, `${JSON.stringify(output)},`, 'utf8', () => {
|
|
91
87
|
fs.close(fd);
|
|
92
88
|
});
|
|
@@ -95,11 +91,9 @@ function afterTest (testData, _context, {passed}) {
|
|
|
95
91
|
}
|
|
96
92
|
|
|
97
93
|
if (!passed) {
|
|
94
|
+
const screenPath = path.join(screenshotRelativePath, 'actual', fileName);
|
|
95
|
+
const diffPath = path.join(screenshotRelativePath, 'diff', fileName);
|
|
98
96
|
fs.open(failedScreenshotFilename, 'a', (err, fd) => {
|
|
99
|
-
const distPath = path.join(process.cwd(), 'tests', 'screenshot', 'dist'),
|
|
100
|
-
diffPath = path.relative(distPath, generateDiffName({test: testData})),
|
|
101
|
-
referencePath = path.relative(distPath, generateReferenceName({test: testData})),
|
|
102
|
-
screenPath = path.relative(distPath, generateScreenshotName({test: testData}));
|
|
103
97
|
if (err) {
|
|
104
98
|
console.error('Unable to create failed test log file!');
|
|
105
99
|
} else {
|
|
@@ -115,7 +109,6 @@ function afterTest (testData, _context, {passed}) {
|
|
|
115
109
|
}
|
|
116
110
|
}
|
|
117
111
|
|
|
118
|
-
|
|
119
112
|
function onComplete () {
|
|
120
113
|
const {size: newSize} = fs.statSync(newScreenshotFilename),
|
|
121
114
|
{size: failedSize} = fs.statSync(failedScreenshotFilename);
|
|
@@ -141,8 +134,9 @@ function onComplete () {
|
|
|
141
134
|
|
|
142
135
|
module.exports = {
|
|
143
136
|
afterTest,
|
|
137
|
+
baselineFolder,
|
|
144
138
|
beforeTest,
|
|
145
|
-
comparator,
|
|
146
139
|
onComplete,
|
|
147
|
-
onPrepare
|
|
140
|
+
onPrepare,
|
|
141
|
+
screenshotFolder
|
|
148
142
|
};
|
package/screenshot/wdio.conf.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
// const visualRegression = require('wdio-novus-visual-regression-service');
|
|
2
1
|
const {configure} = require('../config/wdio.conf.js');
|
|
3
|
-
const {afterTest,
|
|
2
|
+
const {afterTest, baselineFolder, beforeTest, onComplete, onPrepare, screenshotFolder} = require('./utils/confHelpers.js');
|
|
4
3
|
|
|
5
4
|
exports.config = configure({
|
|
6
5
|
base: 'screenshot',
|
|
7
6
|
services: [[
|
|
8
|
-
'
|
|
7
|
+
'image-comparison',
|
|
9
8
|
{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
baselineFolder: baselineFolder,
|
|
10
|
+
formatImageName: '{tag}',
|
|
11
|
+
screenshotPath: screenshotFolder,
|
|
12
|
+
autoSaveBaseline: true
|
|
14
13
|
}
|
|
15
14
|
]],
|
|
16
15
|
//
|
package/ui/wdio.docker.conf.js
CHANGED
|
@@ -3,7 +3,7 @@ const {config} = require('./wdio.conf.js');
|
|
|
3
3
|
|
|
4
4
|
// Remove selenium-standalone and replace with docker service
|
|
5
5
|
const services = config.services
|
|
6
|
-
.filter(service => service !== 'selenium-standalone')
|
|
6
|
+
.filter(service => service[0] !== 'selenium-standalone')
|
|
7
7
|
.concat(['docker']);
|
|
8
8
|
|
|
9
9
|
exports.config = Object.assign(
|
package/utils/runTest.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
const crypto = require('crypto');
|
|
2
3
|
const parseArgs = require('minimist');
|
|
3
4
|
|
|
4
5
|
const args = parseArgs(process.argv);
|
|
@@ -17,7 +18,7 @@ const runTest = ({concurrency, filter, Page, testName, ...rest}) => {
|
|
|
17
18
|
it('should fetch test cases', function () {
|
|
18
19
|
Page.open('?request');
|
|
19
20
|
let testCases = browser.execute(function () {
|
|
20
|
-
return window.__TEST_DATA;
|
|
21
|
+
return window.__TEST_DATA;
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
expect(testCases).to.be.an('object', 'Test data failed to load');
|
|
@@ -48,12 +49,24 @@ const runTest = ({concurrency, filter, Page, testName, ...rest}) => {
|
|
|
48
49
|
testId
|
|
49
50
|
}, rest));
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
const testNameParts = testCase.title.split('~/');
|
|
53
|
+
let testCaseName = testNameParts.pop();
|
|
54
|
+
// Replace problematic filenames. Windows is much more restrictive.
|
|
55
|
+
testCaseName = testCaseName.replace(/[/\\:?*"|<>]/g, '_');
|
|
56
|
+
// shorten the name with a little bit of leading context to help find the file manually if necessary
|
|
57
|
+
testCaseName = testCaseName.substring(0, 128) + '-' + crypto.createHash('md5').update(testCaseName).digest('hex');
|
|
58
|
+
const screenshotFileName = (component + '/' + testName + '/' + testCaseName);
|
|
52
59
|
|
|
53
|
-
const context = {params, component, testName, url: Page.url};
|
|
60
|
+
const context = {params, component, testName, url: Page.url, fileName: screenshotFileName};
|
|
54
61
|
this.test.context = context;
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
|
|
63
|
+
Page.open(`?${params}`);
|
|
64
|
+
|
|
65
|
+
expect(browser.checkScreen(screenshotFileName, {
|
|
66
|
+
disableCSSAnimation: true,
|
|
67
|
+
ignoreNothing: true,
|
|
68
|
+
rawMisMatchPercentage: true
|
|
69
|
+
})).to.equal(0);
|
|
57
70
|
});
|
|
58
71
|
});
|
|
59
72
|
});
|