@enact/ui-test-utils 2.0.1 → 4.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/package.json CHANGED
@@ -1,9 +1,18 @@
1
1
  {
2
2
  "name": "@enact/ui-test-utils",
3
- "version": "2.0.1",
3
+ "version": "4.0.0",
4
4
  "description": "UI Testing for the Enact framework",
5
5
  "repository": "https://github.com/enactjs/ui-test-utils",
6
- "main": "index.js",
6
+ "type": "module",
7
+ "exports": {
8
+ "./screenshot/wdio.conf.js": "./screenshot/wdio.conf.js",
9
+ "./screenshot/wdio.docker.conf.js": "./screenshot/wdio.docker.conf.js",
10
+ "./screenshot/wdio.tv.conf.js": "./screenshot/wdio.tv.conf.js",
11
+ "./ui/wdio.conf.js": "./ui/wdio.conf.js",
12
+ "./ui/wdio.docker.conf.js": "./ui/wdio.docker.conf.js",
13
+ "./ui/wdio.tv.conf.js": "./ui/wdio.tv.conf.js",
14
+ "./utils": "./utils/index.js"
15
+ },
7
16
  "bin": {
8
17
  "start-tests": "./start-tests.js"
9
18
  },
@@ -20,29 +29,28 @@
20
29
  "access": "public"
21
30
  },
22
31
  "dependencies": {
23
- "@wdio/cli": "^9.15.0",
24
- "@wdio/dot-reporter": "^9.15.0",
25
- "@wdio/local-runner": "9.2.1",
26
- "@wdio/mocha-framework": "^9.15.0",
27
- "@wdio/spec-reporter": "^9.15.0",
28
- "@wdio/static-server-service": "^9.15.0",
29
- "@wdio/visual-service": "^8.0.4",
30
- "chalk": "^5.4.1",
32
+ "@wdio/cli": "^9.20.0",
33
+ "@wdio/dot-reporter": "^9.20.0",
34
+ "@wdio/local-runner": "^9.20.0",
35
+ "@wdio/mocha-framework": "^9.20.0",
36
+ "@wdio/spec-reporter": "^9.20.0",
37
+ "@wdio/static-server-service": "^9.20.0",
38
+ "@wdio/visual-service": "^9.0.0",
39
+ "chalk": "^5.6.2",
31
40
  "cross-spawn": "^7.0.6",
32
- "expect-webdriverio": "^5.3.2",
33
- "fs-extra": "^11.3.0",
41
+ "expect-webdriverio": "^5.4.3",
42
+ "fs-extra": "^11.3.2",
34
43
  "minimist": "^1.2.8",
35
44
  "query-string": "^7.1.3",
36
- "ramda": "^0.30.1",
45
+ "ramda": "^0.31.3",
37
46
  "readdirp": "^3.6.0",
38
47
  "wdio-docker-service": "^3.2.1",
39
- "wdio-selenium-standalone-service": "^0.0.12",
40
- "webdriverio": "^9.15.0"
48
+ "webdriverio": "^9.20.0"
41
49
  },
42
50
  "devDependencies": {
43
- "eslint": "^9.29.0",
44
- "eslint-config-enact": "^5.0.1",
45
- "globals": "^16.3.0"
51
+ "eslint": "^9.36.0",
52
+ "eslint-config-enact": "^5.0.2",
53
+ "globals": "^16.4.0"
46
54
  },
47
55
  "overrides": {
48
56
  "cross-spawn": "$cross-spawn",
@@ -1,6 +1,6 @@
1
1
  import {createRoot} from 'react-dom/client';
2
2
  import App, {testMetadata} from 'UI_TEST_APP_ENTRY';
3
- import TestChooser from './TestChooser';
3
+ import TestChooser from './TestChooser.js';
4
4
 
5
5
  const url = new URL(window.location.href);
6
6
 
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "name": "@enact/ss-tests",
3
- "main": "index.js"
3
+ "main": "index.js",
4
+ "type": "module"
4
5
  }
@@ -1,9 +1,9 @@
1
- const cryptoModule = require('crypto'),
2
- path = require('path'),
3
- fs = require('fs');
1
+ import cryptoModule from 'crypto';
2
+ import path from 'path';
3
+ import fs from 'fs';
4
4
 
5
- const buildApps = require('../../src/build-apps');
6
- const makeHeader = require('./headerTemplate');
5
+ import buildApps from '../../src/build-apps.js';
6
+ import {makeHeader} from './headerTemplate.js';
7
7
 
8
8
  const newScreenshotFilename = 'tests/screenshot/dist/newFiles.html',
9
9
  failedScreenshotFilename = 'tests/screenshot/dist/failedTests.html',
@@ -139,8 +139,7 @@ function onComplete () {
139
139
  }
140
140
  }
141
141
 
142
-
143
- module.exports = {
142
+ export {
144
143
  afterTest,
145
144
  baselineFolder,
146
145
  beforeTest,
@@ -1,4 +1,4 @@
1
- module.exports = function (title) {
1
+ export function makeHeader (title) {
2
2
  return `<html>
3
3
  <head>
4
4
  <link rel="stylesheet" href="utils/styles.css">
@@ -31,4 +31,4 @@ module.exports = function (title) {
31
31
  <script>
32
32
  const results = [
33
33
  `;
34
- };
34
+ }
@@ -1,7 +1,7 @@
1
- const {configure} = require('../config/wdio.conf.js');
2
- const {afterTest, baselineFolder, beforeTest, onComplete, onPrepare, screenshotFolder} = require('./utils/confHelpers.js');
1
+ import {configure} from '../config/wdio.conf.js';
2
+ import {afterTest, baselineFolder, beforeTest, onComplete, onPrepare, screenshotFolder} from './utils/confHelpers.js';
3
3
 
4
- exports.config = configure({
4
+ const config = configure({
5
5
  base: 'screenshot',
6
6
  services: [[
7
7
  'visual',
@@ -44,3 +44,6 @@ exports.config = configure({
44
44
  */
45
45
  onComplete: onComplete
46
46
  });
47
+
48
+ export default {config};
49
+ export {config};
@@ -1,14 +1,14 @@
1
- const ipAddress = require('../utils/ipAddress.js');
2
- const {config} = require('./wdio.conf.js');
1
+ import {ipAddress} from '../utils/ipAddress.js';
2
+ import {config as ssConfig} from './wdio.conf.js';
3
3
 
4
4
  // Remove selenium-standalone and replace with docker service
5
- const services = config.services
5
+ const services = ssConfig.services
6
6
  .filter(service => service[0] !== 'selenium-standalone')
7
7
  .concat(['docker']);
8
8
 
9
- exports.config = Object.assign(
9
+ const config = Object.assign(
10
10
  {},
11
- config,
11
+ ssConfig,
12
12
  {
13
13
  baseUrl: `http://${ipAddress()}:4567`,
14
14
  services,
@@ -23,3 +23,5 @@ exports.config = Object.assign(
23
23
  }
24
24
  }
25
25
  );
26
+
27
+ export const ssDockerConfig = {config};
@@ -1,16 +1,16 @@
1
- const ipAddress = require('../utils/ipAddress.js');
2
- const {config} = require('./wdio.conf.js');
1
+ import {ipAddress} from '../utils/ipAddress.js';
2
+ import {config as ssConfig} from './wdio.conf.js';
3
3
 
4
- const services = config.services.map(service => {
4
+ const services = ssConfig.services.map(service => {
5
5
  if (service[0] === 'novus-visual-regression') {
6
6
  delete service[1].viewports;
7
7
  }
8
8
  return service;
9
9
  });
10
10
 
11
- exports.config = Object.assign(
11
+ const config = Object.assign(
12
12
  {},
13
- config,
13
+ ssConfig,
14
14
  {
15
15
  services,
16
16
 
@@ -33,15 +33,9 @@ exports.config = Object.assign(
33
33
  'wdio: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',
41
36
  'goog:chromeOptions': {
42
37
  debuggerAddress: `${process.env.TV_IP}:9998`
43
- },
44
- 'wdio:enforceWebDriverClassic': true
38
+ }
45
39
  }],
46
40
 
47
41
  //
@@ -54,8 +48,8 @@ exports.config = Object.assign(
54
48
  * variables like `browser`. It is the perfect place to define custom commands.
55
49
  */
56
50
  before: function () {
57
- if (config.before) {
58
- config.before();
51
+ if (ssConfig.before) {
52
+ ssConfig.before();
59
53
  }
60
54
 
61
55
  browser._options = {remote: true};
@@ -67,3 +61,5 @@ exports.config = Object.assign(
67
61
  }
68
62
  }
69
63
  );
64
+
65
+ export const ssTVConfig = {config};
package/src/build-apps.js CHANGED
@@ -1,9 +1,10 @@
1
- const path = require('path');
1
+ import path from 'path';
2
2
 
3
3
  let chalk;
4
- const spawn = require('cross-spawn');
5
- const fs = require('fs-extra');
6
- const readdirp = require('readdirp');
4
+ import spawn from 'cross-spawn';
5
+ import fs from 'fs-extra';
6
+ import readdirp from 'readdirp';
7
+ import * as url from 'url';
7
8
 
8
9
  const env = {
9
10
  ILIB_BASE_PATH: '/framework/ilib',
@@ -16,6 +17,9 @@ function findViews (base) {
16
17
  return readdirp.promise(path.join('tests', base, 'apps'), {fileFilter: '*-View.js'});
17
18
  }
18
19
 
20
+ // eslint-disable-next-line no-shadow
21
+ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
22
+
19
23
  function buildApps (base) {
20
24
  if (process.argv.includes('--skip-build')) return;
21
25
  console.log('Building content:\n');
@@ -140,5 +144,6 @@ function epack ({file, opts}) {
140
144
  }
141
145
  }
142
146
 
143
- module.exports = buildApps;
144
- if (require.main === module) buildApps();
147
+ export default buildApps;
148
+ const modulePath = url.fileURLToPath(import.meta.url);
149
+ if (process.argv[1] === modulePath) buildApps();
package/start-tests.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- const cli = require('@wdio/cli');
2
+ import * as cli from '@wdio/cli';
3
3
 
4
4
  cli.run();
package/ui/package.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "name":"@enact/ui-tests",
3
- "main": "index.js"
3
+ "main": "index.js",
4
+ "type": "module"
4
5
  }
package/ui/wdio.conf.js CHANGED
@@ -1,13 +1,13 @@
1
- const buildApps = require('../src/build-apps'),
2
- fs = require('fs');
1
+ import buildApps from '../src/build-apps.js';
2
+ import fs from 'fs';
3
3
  let chalk;
4
4
  import('chalk').then(({default: _chalk}) => {
5
5
  chalk = _chalk;
6
6
  });
7
7
 
8
- const {configure} = require('../config/wdio.conf.js');
8
+ import {configure} from '../config/wdio.conf.js';
9
9
 
10
- exports.config = configure({
10
+ const config = configure({
11
11
  base: 'ui',
12
12
  //
13
13
  // =====
@@ -59,3 +59,6 @@ exports.config = configure({
59
59
  }
60
60
  }
61
61
  });
62
+
63
+ export default {config};
64
+ export {config};
@@ -1,14 +1,14 @@
1
- const ipAddress = require('../utils/ipAddress.js');
2
- const {config} = require('./wdio.conf.js');
1
+ import {ipAddress} from '../utils/ipAddress.js';
2
+ import {config as uiConfig} from './wdio.conf.js';
3
3
 
4
4
  // Remove selenium-standalone and replace with docker service
5
- const services = config.services
5
+ const services = uiConfig.services
6
6
  .filter(service => service[0] !== 'selenium-standalone')
7
7
  .concat(['docker']);
8
8
 
9
- exports.config = Object.assign(
9
+ const config = Object.assign(
10
10
  {},
11
- config,
11
+ uiConfig,
12
12
  {
13
13
  baseUrl: `http://${ipAddress()}:4567`,
14
14
  services,
@@ -23,3 +23,5 @@ exports.config = Object.assign(
23
23
  }
24
24
  }
25
25
  );
26
+
27
+ export const uiDockerConfig = {config};
@@ -1,9 +1,9 @@
1
- const ipAddress = require('../utils/ipAddress.js');
2
- const {config} = require('./wdio.conf.js');
1
+ import {ipAddress} from '../utils/ipAddress.js';
2
+ import {config as uiConfig} from './wdio.conf.js';
3
3
 
4
- exports.config = Object.assign(
4
+ const config = Object.assign(
5
5
  {},
6
- config,
6
+ uiConfig,
7
7
  {
8
8
  capabilities: [{
9
9
  // maxInstances can get overwritten per capability. So if you have an in-house Selenium
@@ -12,25 +12,21 @@ exports.config = Object.assign(
12
12
  'wdio:maxInstances': 1,
13
13
  //
14
14
  browserName: 'chrome',
15
- /* WebdriverIO v8.14 and above downloads and uses the latest Chrome version when running tests.
16
- We need to specify a browser version that match chromedriver version running in CI/CD environment to
17
- ensure testing accuracy.
18
- TODO: Update this version when chromedriver version in CI/CD is updated */
19
- browserVersion: '120.0.6099.109',
20
15
  'goog:chromeOptions': {
21
16
  debuggerAddress: `${process.env.TV_IP}:9998`
22
- },
23
- 'wdio:enforceWebDriverClassic': true
17
+ }
24
18
  }],
25
19
 
26
20
  baseUrl: `http://${ipAddress()}:4567`,
27
21
 
28
22
  before: function () {
29
- if (config.before) {
30
- config.before();
23
+ if (uiConfig.before) {
24
+ uiConfig.before();
31
25
  }
32
26
 
33
27
  browser._options = {remote: true};
34
28
  }
35
29
  }
36
30
  );
31
+
32
+ export const uiTVConfig = {config};
package/utils/Page.js CHANGED
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ import queryString from 'query-string';
2
2
 
3
- const queryString = require('query-string');
4
-
5
- class Page {
3
+ export class Page {
6
4
  constructor () {
7
5
  this.title = 'Untitled Test';
8
6
  this._url = '';
@@ -18,15 +16,11 @@ class Page {
18
16
  });
19
17
 
20
18
  this._url = `/${appPath}/${urlExtra}`;
21
- // Can't resize browser window when connected to remote debugger!
22
- if (!browser._options || !browser._options.remote) {
23
- await browser.setWindowSize(1920, 1080);
24
- }
25
19
 
26
20
  await browser.url(this.url);
27
21
 
28
22
  const body = await $('body');
29
- await body.waitForDisplayed({timeout: 5000});
23
+ await body.waitForDisplayed({timeout: 10000});
30
24
 
31
25
  await this.delay(200);
32
26
  }
@@ -170,7 +164,3 @@ class Page {
170
164
  );
171
165
  }
172
166
  }
173
-
174
- module.exports = {
175
- Page
176
- };
@@ -75,7 +75,7 @@ const stringifyProps = (props = {}) => {
75
75
  return formattedString.length === 0 ? 'default' : formattedString;
76
76
  };
77
77
 
78
- const generateTestData = (component, componentTests) => {
78
+ export const generateTestData = (component, componentTests) => {
79
79
  let metaData = [];
80
80
  componentTests.forEach((testCase) => {
81
81
  let title = testCase.title;
@@ -104,7 +104,3 @@ const generateTestData = (component, componentTests) => {
104
104
 
105
105
  return metaData;
106
106
  };
107
-
108
- module.exports = {
109
- generateTestData
110
- };
package/utils/index.js CHANGED
@@ -1,7 +1,7 @@
1
- const {generateTestData} = require('./generateTestData');
2
- const {Page} = require('./Page');
3
- const {runTest} = require('./runTest');
4
- const {
1
+ import {generateTestData} from './generateTestData.js';
2
+ import {Page} from './Page.js';
3
+ import {runTest} from './runTest.js';
4
+ import {
5
5
  componentSelector,
6
6
  element,
7
7
  expectOrdering,
@@ -9,10 +9,10 @@ const {
9
9
  getSubComponent,
10
10
  getText,
11
11
  hasClass
12
- } = require('./selector');
13
- const {generateDate, urlParamsToObject} = require('./qs');
12
+ } from './selector.js';
13
+ import {generateDate, urlParamsToObject} from './qs.js';
14
14
 
15
- module.exports = {
15
+ export {
16
16
  componentSelector,
17
17
  element,
18
18
  expectOrdering,
@@ -1,4 +1,4 @@
1
- const os = require('os');
1
+ import os from 'os';
2
2
 
3
3
  function ipAddress () {
4
4
  const ifaces = os.networkInterfaces();
@@ -17,4 +17,4 @@ function ipAddress () {
17
17
  return address;
18
18
  }
19
19
 
20
- module.exports = ipAddress;
20
+ export {ipAddress};
package/utils/qs.js CHANGED
@@ -1,4 +1,4 @@
1
- const queryString = require('query-string');
1
+ import queryString from 'query-string';
2
2
 
3
3
  const isJson = (str) => {
4
4
  try {
@@ -9,7 +9,7 @@ const isJson = (str) => {
9
9
  return true;
10
10
  };
11
11
 
12
- const urlParamsToObject = (query = window.location.search) => {
12
+ export const urlParamsToObject = (query = window.location.search) => {
13
13
  let parsed = queryString.parse(query);
14
14
  delete parsed.locale;
15
15
 
@@ -23,7 +23,7 @@ const urlParamsToObject = (query = window.location.search) => {
23
23
  };
24
24
 
25
25
  // Generate a date (without time component) from a string in the format YYYY-MM-DD
26
- const generateDate = dateStr => {
26
+ export const generateDate = dateStr => {
27
27
  const date = new Date(),
28
28
  values = dateStr.match(/(\d{4})-(\d{2})-(\d{2})/);
29
29
 
@@ -40,8 +40,3 @@ const generateDate = dateStr => {
40
40
 
41
41
  return date;
42
42
  };
43
-
44
- module.exports = {
45
- generateDate,
46
- urlParamsToObject
47
- };
package/utils/runTest.js CHANGED
@@ -1,6 +1,5 @@
1
- 'use strict';
2
- const cryptoModule = require('crypto');
3
- const parseArgs = require('minimist');
1
+ import cryptoModule from 'crypto';
2
+ import parseArgs from 'minimist';
4
3
 
5
4
  const args = parseArgs(process.argv);
6
5
 
@@ -9,7 +8,7 @@ const pattern = args.component, // Component group to match
9
8
  titlePattern = args.title, // Pattern for matching test case title
10
9
  maxInstances = args.instances || 5; // concurrent instances for 'manual' concurrency
11
10
 
12
- const runTest = ({concurrency, filter, Page, testName, ...rest}) => {
11
+ export const runTest = ({concurrency, filter, Page, testName, ...rest}) => {
13
12
  if (concurrency && (concurrency > maxInstances)) {
14
13
  return;
15
14
  }
@@ -65,6 +64,7 @@ const runTest = ({concurrency, filter, Page, testName, ...rest}) => {
65
64
 
66
65
  expect(await browser.checkScreen(screenshotFileName, {
67
66
  disableCSSAnimation: true,
67
+ ignoreAntialiasing: true,
68
68
  ignoreNothing: true,
69
69
  rawMisMatchPercentage: true,
70
70
  waitForFontsLoaded: true
@@ -77,7 +77,3 @@ const runTest = ({concurrency, filter, Page, testName, ...rest}) => {
77
77
  });
78
78
  });
79
79
  };
80
-
81
- module.exports = {
82
- runTest
83
- };
package/utils/selector.js CHANGED
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- const curry = require('ramda/src/curry');
1
+ import curry from 'ramda/src/curry';
4
2
 
5
3
  const toLower = (str) => str.replace(/^\w/, (chr) => chr.toLowerCase());
6
4
 
@@ -54,7 +52,7 @@ const hasClass = curry(async (className, el) => {
54
52
  return elementClass.includes(className);
55
53
  });
56
54
 
57
- module.exports = {
55
+ export {
58
56
  componentSelector,
59
57
  element,
60
58
  expectOrdering,