@enact/ui-test-utils 1.0.10 → 2.0.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/ui-test-utils",
3
- "version": "1.0.10",
3
+ "version": "2.0.0-alpha.2",
4
4
  "description": "UI Testing for the Enact framework",
5
5
  "repository": "https://github.com/enactjs/ui-test-utils",
6
6
  "main": "index.js",
@@ -14,38 +14,39 @@
14
14
  "author": "Roy Sutton <roy.sutton@lge.com>",
15
15
  "license": "Apache-2.0",
16
16
  "engines": {
17
- "node": ">=14.14.0"
17
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
18
18
  },
19
19
  "publishConfig": {
20
20
  "access": "public"
21
21
  },
22
22
  "dependencies": {
23
- "@wdio/cli": "^7.36.0",
24
- "@wdio/dot-reporter": "^7.33.0",
25
- "@wdio/local-runner": "^7.36.0",
26
- "@wdio/mocha-framework": "^7.33.0",
27
- "@wdio/selenium-standalone-service": "^7.33.0",
28
- "@wdio/spec-reporter": "^7.33.0",
29
- "@wdio/static-server-service": "^7.33.0",
30
- "chalk": "^5.3.0",
31
- "cross-spawn": "^7.0.3",
32
- "expect-webdriverio": "^3.6.0",
33
- "fs-extra": "^11.2.0",
23
+ "@wdio/cli": "^9.10.0",
24
+ "@wdio/dot-reporter": "^9.9.0",
25
+ "@wdio/local-runner": "9.2.1",
26
+ "@wdio/mocha-framework": "^9.9.0",
27
+ "@wdio/spec-reporter": "^9.9.0",
28
+ "@wdio/static-server-service": "^9.9.0",
29
+ "@wdio/visual-service": "^6.3.2",
30
+ "chalk": "^5.4.1",
31
+ "cross-spawn": "^7.0.6",
32
+ "expect-webdriverio": "^5.1.0",
33
+ "fs-extra": "^11.3.0",
34
34
  "minimist": "^1.2.8",
35
35
  "query-string": "^7.1.3",
36
36
  "ramda": "^0.30.1",
37
37
  "readdirp": "^3.6.0",
38
38
  "wdio-docker-service": "^3.2.1",
39
- "wdio-image-comparison-service": "^5.0.3",
40
- "webdriverio": "^7.36.0"
39
+ "wdio-selenium-standalone-service": "^0.0.12",
40
+ "webdriverio": "^9.10.0"
41
41
  },
42
42
  "devDependencies": {
43
- "eslint": "^8.57.0",
44
- "eslint-config-enact": "^4.2.1",
45
- "eslint-config-prettier": "^9.1.0",
46
- "eslint-plugin-import": "^2.30.0"
43
+ "eslint": "^9.21.0",
44
+ "eslint-config-enact": "^5.0.0-alpha.5",
45
+ "globals": "^15.14.0"
47
46
  },
48
47
  "overrides": {
48
+ "cross-spawn": "$cross-spawn",
49
+ "express": "^4.21.2",
49
50
  "ws": "^8.18.0"
50
51
  }
51
52
  }
@@ -20,7 +20,7 @@ function getScreenshotName (basePath) {
20
20
  // Replace problematic filenames. Windows is much more restrictive.
21
21
  testName = testName.replace(/[/\\:?*"|<>]/g, '_');
22
22
 
23
- // shorten the name with a little bit of leading context to help find the file manually if necessary
23
+ // shorten the name with a bit of leading context to help find the file manually if necessary
24
24
  testName = testName.substring(0, 128) + '-' + cryptoModule.createHash('md5').update(testName).digest('hex');
25
25
  let screenshotFileName = path.join(basePath, ...testNameParts, `${testName}.png`);
26
26
  return screenshotFileName.replace(/ /g, '_');
@@ -67,6 +67,14 @@ function beforeTest (testData) {
67
67
  if (testData && testData.title && testData.title.indexOf('/') > 0) {
68
68
  const filename = generateReferenceName({test: testData});
69
69
  testData.ctx.isNewScreenshot = !fs.existsSync(filename);
70
+
71
+ // if there are no reference screenshots, we must create the folder before running the tests.
72
+ const specsPath = testData.title.split('~/');
73
+ specsPath.pop();
74
+ const referenceSpecsPath = path.join('tests/screenshot/dist/screenshots/reference', ...specsPath).replace(/ /g, '_');
75
+ if (testData.ctx.isNewScreenshot) {
76
+ fs.mkdirSync(referenceSpecsPath, {recursive: true});
77
+ }
70
78
  }
71
79
  }
72
80
 
@@ -4,12 +4,13 @@ const {afterTest, baselineFolder, beforeTest, onComplete, onPrepare, screenshotF
4
4
  exports.config = configure({
5
5
  base: 'screenshot',
6
6
  services: [[
7
- 'image-comparison',
7
+ 'visual',
8
8
  {
9
9
  baselineFolder: baselineFolder,
10
10
  formatImageName: '{tag}',
11
11
  screenshotPath: screenshotFolder,
12
- autoSaveBaseline: true
12
+ autoSaveBaseline: true,
13
+ waitForFontsLoaded: true
13
14
  }
14
15
  ]],
15
16
  //
@@ -33,10 +33,15 @@ exports.config = Object.assign(
33
33
  maxInstances: 1,
34
34
  //
35
35
  browserName: 'chrome',
36
+ /* WebdriverIO v8.14 and above downloads and uses the latest Chrome version when running tests.
37
+ We need to specify a browser version that match chromedriver version running in CI/CD environment to
38
+ ensure testing accuracy.
39
+ TODO: Update this version when chromedriver version in CI/CD is updated */
40
+ browserVersion: '120.0.6099.109',
36
41
  'goog:chromeOptions': {
37
- w3c: false,
38
42
  debuggerAddress: `${process.env.TV_IP}:9998`
39
- }
43
+ },
44
+ 'wdio:enforceWebDriverClassic': true
40
45
  }],
41
46
 
42
47
  //
@@ -47,8 +52,6 @@ exports.config = Object.assign(
47
52
  /**
48
53
  * Gets executed before test execution begins. At this point you can access to all global
49
54
  * variables like `browser`. It is the perfect place to define custom commands.
50
- * @param {Array.<Object>} capabilities list of capabilities details
51
- * @param {Array.<String>} specs List of spec file paths that are to be run
52
55
  */
53
56
  before: function () {
54
57
  if (config.before) {
package/src/build-apps.js CHANGED
@@ -31,7 +31,8 @@ function buildApps (base) {
31
31
  '--output',
32
32
  path.join('tests', base, 'dist', 'framework'),
33
33
  '--framework',
34
- '--externals-polyfill'
34
+ '--externals-polyfill',
35
+ process.argv.includes('--no-animation') ? '--no-animation' : null
35
36
  ]
36
37
  });
37
38
  }
package/ui/wdio.conf.js CHANGED
@@ -19,15 +19,17 @@ exports.config = configure({
19
19
  // resolved to continue.
20
20
  /**
21
21
  * Gets executed once before all workers get launched.
22
- * @param {Object} config wdio configuration object
23
- * @param {Array.<Object>} capabilities list of capabilities details
24
22
  */
25
23
  onPrepare: function () {
26
24
  return buildApps('ui');
27
25
  },
28
26
  /**
29
27
  * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
30
- * @param {Object} test test details
28
+ * @param {Object} testCase test details
29
+ * @param {Object} _context scope object the test was executed with (unused)
30
+ * @param {Object} result test result
31
+ * @param {Number} result.duration duration of test
32
+ * @param {Boolean} result.passed true if test has passed, otherwise false
31
33
  */
32
34
  afterTest: function (testCase, _context, {duration, passed}) {
33
35
  if (duration > 2000) {
@@ -9,10 +9,15 @@ exports.config = Object.assign(
9
9
  maxInstances: 1,
10
10
 
11
11
  browserName: 'chrome',
12
+ /* WebdriverIO v8.14 and above downloads and uses the latest Chrome version when running tests.
13
+ We need to specify a browser version that match chromedriver version running in CI/CD environment to
14
+ ensure testing accuracy.
15
+ TODO: Update this version when chromedriver version in CI/CD is updated */
16
+ browserVersion: '120.0.6099.109',
12
17
  'goog:chromeOptions': {
13
- w3c: false,
14
18
  debuggerAddress: `${process.env.TV_IP}:9998`
15
- }
19
+ },
20
+ 'wdio:enforceWebDriverClassic': true
16
21
  }],
17
22
 
18
23
  baseUrl: `http://${ipAddress()}:4567`,
package/utils/runTest.js CHANGED
@@ -54,7 +54,7 @@ const runTest = ({concurrency, filter, Page, testName, ...rest}) => {
54
54
  let testCaseName = testNameParts.pop();
55
55
  // Replace problematic filenames. Windows is much more restrictive.
56
56
  testCaseName = testCaseName.replace(/[/\\:?*"|<>]/g, '_');
57
- // shorten the name with a little bit of leading context to help find the file manually if necessary
57
+ // shorten the name with a bit of leading context to help find the file manually if necessary
58
58
  testCaseName = testCaseName.substring(0, 128) + '-' + cryptoModule.createHash('md5').update(testCaseName).digest('hex');
59
59
  const screenshotFileName = (component + '/' + testName + '/' + testCaseName);
60
60
 
@@ -66,7 +66,8 @@ const runTest = ({concurrency, filter, Page, testName, ...rest}) => {
66
66
  expect(await browser.checkScreen(screenshotFileName, {
67
67
  disableCSSAnimation: true,
68
68
  ignoreNothing: true,
69
- rawMisMatchPercentage: true
69
+ rawMisMatchPercentage: true,
70
+ waitForFontsLoaded: true
70
71
  })).toBe(0);
71
72
  });
72
73
  });
package/.eslintrc.js DELETED
@@ -1,25 +0,0 @@
1
- module.exports = {
2
- globals: {
3
- 'browser': true,
4
- 'expect': true,
5
- '$': true,
6
- '$$': true
7
- },
8
- env: {
9
- mocha: true,
10
- node: true
11
- },
12
- extends: 'enact/strict',
13
- parserOptions: {
14
- ecmaFeatures: {
15
- jsx: true
16
- },
17
- ecmaVersion: 'latest',
18
- sourceType: 'module'
19
- },
20
- rules: {
21
- 'max-nested-callbacks': 'off',
22
- 'no-console': 'off',
23
- 'react/forbid-foreign-prop-types': 'off' // proptypes not removed in storybook config
24
- }
25
- };