Skip to content

Commit 934e0fd

Browse files
committed
chore: ESM conversion - Phase 3
Convert major helper files to ES modules: - lib/helper/Puppeteer.js: Convert require() to import, export default - lib/helper/WebDriver.js: Convert require() to import - Remove duplicate exports in Puppeteer.js These are the three main browser automation helpers. Next: Convert remaining helpers, plugins, and listener files
1 parent d277565 commit 934e0fd

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

lib/helper/Puppeteer.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ import {
2626
isModifierKey,
2727
requireWithFallback,
2828
normalizeSpacesInString,
29-
} = require('../utils')
30-
const { isColorProperty, convertColorToRGBA } = require('../colorUtils')
31-
const ElementNotFound = require('./errors/ElementNotFound')
32-
const RemoteBrowserConnectionRefused = require('./errors/RemoteBrowserConnectionRefused')
33-
const Popup = require('./extras/Popup')
34-
const Console = require('./extras/Console')
35-
const { highlightElement } = require('./scripts/highlightElement')
36-
const { blurElement } = require('./scripts/blurElement')
37-
const { dontSeeElementError, seeElementError, dontSeeElementInDOMError, seeElementInDOMError } = require('./errors/ElementAssertion')
38-
const { dontSeeTraffic, seeTraffic, grabRecordedNetworkTraffics, stopRecordingTraffic, flushNetworkTraffics } = require('./network/actions')
39-
const WebElement = require('../element/WebElement')
29+
} from '../utils.js'
30+
import { isColorProperty, convertColorToRGBA } from '../colorUtils.js'
31+
import ElementNotFound from './errors/ElementNotFound.js'
32+
import RemoteBrowserConnectionRefused from './errors/RemoteBrowserConnectionRefused.js'
33+
import Popup from './extras/Popup.js'
34+
import Console from './extras/Console.js'
35+
import { highlightElement } from './scripts/highlightElement.js'
36+
import { blurElement } from './scripts/blurElement.js'
37+
import { dontSeeElementError, seeElementError, dontSeeElementInDOMError, seeElementInDOMError } from './errors/ElementAssertion.js'
38+
import { dontSeeTraffic, seeTraffic, grabRecordedNetworkTraffics, stopRecordingTraffic, flushNetworkTraffics } from './network/actions.js'
39+
import WebElement from '../element/WebElement.js'
4040

4141
let puppeteer
4242

@@ -2847,7 +2847,7 @@ class Puppeteer extends Helper {
28472847
}
28482848
}
28492849

2850-
module.exports = Puppeteer
2850+
export default Puppeteer
28512851

28522852
/**
28532853
* Find elements using Puppeteer's native element discovery methods
@@ -3455,4 +3455,3 @@ function createRoleTextMatcher(expected, exactMatch) {
34553455
return value => typeof value === 'string' && value.includes(target)
34563456
}
34573457

3458-
export { Puppeteer as default }

lib/helper/WebDriver.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
let webdriverio
22

3-
const assert = require('assert')
4-
const path = require('path')
5-
6-
const Helper = require('@codeceptjs/helper')
7-
const promiseRetry = require('promise-retry')
8-
const stringIncludes = require('../assert/include').includes
9-
const { urlEquals, equals } = require('../assert/equal')
10-
const store = require('../store')
11-
const { debug } = require('../output')
12-
const { empty } = require('../assert/empty')
13-
const { truth } = require('../assert/truth')
14-
const { xpathLocator, fileExists, decodeUrl, chunkArray, convertCssPropertiesToCamelCase, screenshotOutputFolder, getNormalizedKeyAttributeValue, modifierKeys } = require('../utils')
15-
const { isColorProperty, convertColorToRGBA } = require('../colorUtils')
16-
const ElementNotFound = require('./errors/ElementNotFound')
17-
const ConnectionRefused = require('./errors/ConnectionRefused')
18-
const Locator = require('../locator')
19-
const { highlightElement } = require('./scripts/highlightElement')
20-
const { focusElement } = require('./scripts/focusElement')
21-
const { blurElement } = require('./scripts/blurElement')
22-
const { dontSeeElementError, seeElementError, seeElementInDOMError, dontSeeElementInDOMError } = require('./errors/ElementAssertion')
23-
const { dontSeeTraffic, seeTraffic, grabRecordedNetworkTraffics, stopRecordingTraffic, flushNetworkTraffics } = require('./network/actions')
24-
const WebElement = require('../element/WebElement')
3+
import assert from 'assert'
4+
import path from 'path'
5+
6+
import Helper from '@codeceptjs/helper'
7+
import promiseRetry from 'promise-retry'
8+
import { includes as stringIncludes } from '../assert/include.js'
9+
import { urlEquals, equals } from '../assert/equal.js'
10+
import store from '../store.js'
11+
import output from '../output.js'
12+
const { debug } = output
13+
import { empty } from '../assert/empty.js'
14+
import { truth } from '../assert/truth.js'
15+
import { xpathLocator, fileExists, decodeUrl, chunkArray, convertCssPropertiesToCamelCase, screenshotOutputFolder, getNormalizedKeyAttributeValue, modifierKeys } from '../utils.js'
16+
import { isColorProperty, convertColorToRGBA } from '../colorUtils.js'
17+
import ElementNotFound from './errors/ElementNotFound.js'
18+
import ConnectionRefused from './errors/ConnectionRefused.js'
19+
import Locator from '../locator.js'
20+
import { highlightElement } from './scripts/highlightElement.js'
21+
import { focusElement } from './scripts/focusElement.js'
22+
import { blurElement } from './scripts/blurElement.js'
23+
import { dontSeeElementError, seeElementError, seeElementInDOMError, dontSeeElementInDOMError } from './errors/ElementAssertion.js'
24+
import { dontSeeTraffic, seeTraffic, grabRecordedNetworkTraffics, stopRecordingTraffic, flushNetworkTraffics } from './network/actions.js'
25+
import WebElement from '../element/WebElement.js'
2526

2627
const SHADOW = 'shadow'
2728
const webRoot = 'body'

0 commit comments

Comments
 (0)