@enact/ui-test-utils 2.0.1 → 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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## [3.0.0] (July 30, 2025)
4
+
5
+ * Migrated to ESM
6
+
3
7
  ## [2.0.1] (July 18, 2025)
4
8
 
5
9
  * Updated dependencies.
package/README.md CHANGED
@@ -9,29 +9,29 @@ and must be configured as a `devDependency` of the UI library.
9
9
  1. Add `@enact/ui-test-utils` as a devDependency: `npm i --save-dev @enact/ui-test-utils`
10
10
  2. Create the `tests/ui` folder structure within the UI library
11
11
  3. Add `apps` and `specs` folders to `tests/ui`
12
- 4. Add local WebDriver configuration files within `tests/ui`
12
+ 4. Add local WebDriver configuration files within `tests/ui/config`
13
13
 
14
- * `wdio.conf.js` containing `module.exports = require('@enact/ui-test-utils/ui/wdio.conf.js');`
15
- * `wdio.docker.conf.js` containing `module.exports = require('@enact/ui-test-utils/ui/wdio.docker.conf.js');`
16
- * `wdio.tv.conf.js` containing `module.exports = require('@enact/ui-test-utils/ui/wdio.tv.conf.js');`
14
+ * `wdio.conf.js` containing `import config from '@enact/ui-test-utils/ui/wdio.conf.js'; export default uiConfig;`
15
+ * `wdio.docker.conf.js` containing `import {uiDockerConfig} from '@enact/ui-test-utils/ui/wdio.docker.conf.js'; export default config;`
16
+ * `wdio.tv.conf.js` containing `import {uiTVConfig} from '@enact/ui-test-utils/ui/wdio.tv.conf.js'; export default config;`
17
17
 
18
- * and `tests/screenshot`
18
+ * and `tests/screenshot/config`
19
19
 
20
- * `wdio.conf.js` containing `module.exports = require('@enact/ui-test-utils/screenshot/wdio.conf.js');`
21
- * `wdio.docker.conf.js` containing `module.exports = require('@enact/ui-test-utils/screenshot/wdio.docker.conf.js');`
22
- * `wdio.tv.conf.js` containing `module.exports = require('@enact/ui-test-utils/screenshot/wdio.tv.conf.js');`
20
+ * `wdio.conf.js` containing `import config from '@enact/ui-test-utils/screenshot/wdio.conf.js'; export default ssConfig;`
21
+ * `wdio.docker.conf.js` containing `import {ssDockerConfig} from '@enact/ui-test-utils/screenshot/wdio.docker.conf.js'; export default config;`
22
+ * `wdio.tv.conf.js` containing `import {ssTVConfig} from '@enact/ui-test-utils/screenshot/wdio.tv.conf.js'; export default config;`
23
23
 
24
24
  5. Add npm scripts for each of the above configuration files. There are likely other scripts already
25
25
  defined so these will be added to the existing scripts.
26
26
 
27
27
  ```json
28
28
  "scripts": {
29
- "test-ui": "start-tests tests/ui/wdio.conf.js",
30
- "test-ui-docker": "start-tests tests/ui/wdio.docker.conf.js",
31
- "test-ui-tv": "start-tests tests/ui/wdio.tv.conf.js",
32
- "test-ss": "start-tests tests/screenshot/wdio.conf.js",
33
- "test-ss-docker": "start-tests tests/screenshot/wdio.docker.conf.js",
34
- "test-ss-tv": "start-tests tests/screenshot/wdio.tv.conf.js",
29
+ "test-ui": "start-tests tests/ui/config/wdio.conf.js",
30
+ "test-ui-docker": "start-tests tests/ui/config/wdio.docker.conf.js",
31
+ "test-ui-tv": "start-tests tests/ui/config/wdio.tv.conf.js",
32
+ "test-ss": "start-tests tests/screenshot/config/wdio.conf.js",
33
+ "test-ss-docker": "start-tests tests/screenshot/config/wdio.docker.conf.js",
34
+ "test-ss-tv": "start-tests tests/screenshot/config/wdio.tv.conf.js",
35
35
  }
36
36
  ```
37
37
 
@@ -1,5 +1,5 @@
1
- const parseArgs = require('minimist');
2
- const {execSync} = require('child_process');
1
+ import parseArgs from 'minimist';
2
+ import {execSync} from 'child_process';
3
3
 
4
4
  const args = parseArgs(process.argv);
5
5
 
@@ -7,7 +7,7 @@ const visibleBrowser = !!args.visible,
7
7
  maxInstances = args.instances || 5,
8
8
  offline = args.offline;
9
9
 
10
- module.exports.configure = (options) => {
10
+ export const configure = (options) => {
11
11
  const {base, services} = options;
12
12
  const opts = Object.assign({}, options);
13
13
 
@@ -83,7 +83,7 @@ module.exports.configure = (options) => {
83
83
  // the config file unless it's absolute.
84
84
  //
85
85
  specs: [
86
- '../../tests/' + base + '/specs/**/*-specs.js'
86
+ '../../../tests/' + base + '/specs/**/*-specs.js'
87
87
  ],
88
88
  // Patterns to exclude.
89
89
  exclude: [
@@ -220,8 +220,6 @@ module.exports.configure = (options) => {
220
220
  * variables like `browser`. It is the perfect place to define custom commands.
221
221
  */
222
222
  before: function () {
223
- require('expect-webdriverio');
224
-
225
223
  global.wdioExpect = global.expect;
226
224
 
227
225
  if (options.before) {
package/eslint.config.js CHANGED
@@ -1,5 +1,5 @@
1
- const enactStrict = require('eslint-config-enact/strict');
2
- const globals = require('globals');
1
+ import enactStrict from 'eslint-config-enact/strict.js';
2
+ import globals from 'globals';
3
3
 
4
4
  const customGlobals = {
5
5
  'browser': true,
@@ -8,7 +8,7 @@ const customGlobals = {
8
8
  '$$': true
9
9
  };
10
10
 
11
- module.exports = [
11
+ export default [
12
12
  ...enactStrict,
13
13
  {
14
14
  languageOptions: {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@enact/ui-test-utils",
3
- "version": "2.0.1",
3
+ "version": "3.0.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@enact/ui-test-utils",
9
- "version": "2.0.1",
9
+ "version": "3.0.0",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@wdio/cli": "^9.15.0",
package/package.json CHANGED
@@ -1,9 +1,18 @@
1
1
  {
2
2
  "name": "@enact/ui-test-utils",
3
- "version": "2.0.1",
3
+ "version": "3.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
  },
@@ -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
 
@@ -54,8 +54,8 @@ exports.config = Object.assign(
54
54
  * variables like `browser`. It is the perfect place to define custom commands.
55
55
  */
56
56
  before: function () {
57
- if (config.before) {
58
- config.before();
57
+ if (ssConfig.before) {
58
+ ssConfig.before();
59
59
  }
60
60
 
61
61
  browser._options = {remote: true};
@@ -67,3 +67,5 @@ exports.config = Object.assign(
67
67
  }
68
68
  }
69
69
  );
70
+
71
+ 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
@@ -26,11 +26,13 @@ exports.config = Object.assign(
26
26
  baseUrl: `http://${ipAddress()}:4567`,
27
27
 
28
28
  before: function () {
29
- if (config.before) {
30
- config.before();
29
+ if (uiConfig.before) {
30
+ uiConfig.before();
31
31
  }
32
32
 
33
33
  browser._options = {remote: true};
34
34
  }
35
35
  }
36
36
  );
37
+
38
+ 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 = '';
@@ -170,7 +168,3 @@ class Page {
170
168
  );
171
169
  }
172
170
  }
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
  }
@@ -77,7 +76,3 @@ const runTest = ({concurrency, filter, Page, testName, ...rest}) => {
77
76
  });
78
77
  });
79
78
  };
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,