codeceptjs 4.0.0-beta.5 → 4.0.0-beta.6.esm-aria
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/README.md +0 -45
- package/bin/codecept.js +46 -57
- package/lib/actor.js +15 -11
- package/lib/ai.js +6 -5
- package/lib/assert/empty.js +9 -8
- package/lib/assert/equal.js +15 -17
- package/lib/assert/error.js +2 -2
- package/lib/assert/include.js +9 -11
- package/lib/assert/throws.js +1 -1
- package/lib/assert/truth.js +8 -5
- package/lib/assert.js +18 -18
- package/lib/codecept.js +66 -107
- package/lib/colorUtils.js +48 -50
- package/lib/command/check.js +32 -27
- package/lib/command/configMigrate.js +11 -10
- package/lib/command/definitions.js +16 -10
- package/lib/command/dryRun.js +16 -16
- package/lib/command/generate.js +29 -26
- package/lib/command/gherkin/init.js +36 -38
- package/lib/command/gherkin/snippets.js +14 -14
- package/lib/command/gherkin/steps.js +21 -18
- package/lib/command/info.js +8 -8
- package/lib/command/init.js +34 -31
- package/lib/command/interactive.js +11 -10
- package/lib/command/list.js +10 -9
- package/lib/command/run-multiple/chunk.js +5 -5
- package/lib/command/run-multiple/collection.js +5 -5
- package/lib/command/run-multiple/run.js +3 -3
- package/lib/command/run-multiple.js +16 -13
- package/lib/command/run-rerun.js +6 -7
- package/lib/command/run-workers.js +10 -24
- package/lib/command/run.js +8 -8
- package/lib/command/utils.js +20 -18
- package/lib/command/workers/runTests.js +117 -269
- package/lib/config.js +111 -49
- package/lib/container.js +299 -102
- package/lib/data/context.js +6 -5
- package/lib/data/dataScenarioConfig.js +1 -1
- package/lib/data/dataTableArgument.js +1 -1
- package/lib/data/table.js +1 -1
- package/lib/effects.js +94 -10
- package/lib/els.js +11 -9
- package/lib/event.js +11 -10
- package/lib/globals.js +141 -0
- package/lib/heal.js +12 -12
- package/lib/helper/AI.js +1 -1
- package/lib/helper/ApiDataFactory.js +16 -13
- package/lib/helper/FileSystem.js +32 -12
- package/lib/helper/GraphQL.js +1 -1
- package/lib/helper/GraphQLDataFactory.js +1 -1
- package/lib/helper/JSONResponse.js +19 -30
- package/lib/helper/Mochawesome.js +9 -28
- package/lib/helper/Playwright.js +668 -265
- package/lib/helper/Puppeteer.js +284 -169
- package/lib/helper/REST.js +29 -12
- package/lib/helper/WebDriver.js +191 -71
- package/lib/helper/errors/ConnectionRefused.js +6 -6
- package/lib/helper/errors/ElementAssertion.js +11 -16
- package/lib/helper/errors/ElementNotFound.js +5 -9
- package/lib/helper/errors/RemoteBrowserConnectionRefused.js +5 -5
- package/lib/helper/extras/Console.js +11 -11
- package/lib/helper/extras/PlaywrightLocator.js +110 -0
- package/lib/helper/extras/PlaywrightPropEngine.js +18 -18
- package/lib/helper/extras/PlaywrightRestartOpts.js +23 -23
- package/lib/helper/extras/Popup.js +1 -1
- package/lib/helper/extras/React.js +29 -30
- package/lib/helper/network/actions.js +33 -48
- package/lib/helper/network/utils.js +76 -83
- package/lib/helper/scripts/blurElement.js +6 -6
- package/lib/helper/scripts/focusElement.js +6 -6
- package/lib/helper/scripts/highlightElement.js +9 -9
- package/lib/helper/scripts/isElementClickable.js +34 -34
- package/lib/helper.js +2 -1
- package/lib/history.js +23 -20
- package/lib/hooks.js +10 -10
- package/lib/html.js +90 -100
- package/lib/index.js +48 -21
- package/lib/listener/config.js +8 -9
- package/lib/listener/emptyRun.js +6 -7
- package/lib/listener/exit.js +4 -3
- package/lib/listener/globalRetry.js +5 -5
- package/lib/listener/globalTimeout.js +11 -10
- package/lib/listener/helpers.js +33 -14
- package/lib/listener/mocha.js +3 -4
- package/lib/listener/result.js +4 -5
- package/lib/listener/steps.js +7 -18
- package/lib/listener/store.js +3 -3
- package/lib/locator.js +213 -192
- package/lib/mocha/asyncWrapper.js +108 -75
- package/lib/mocha/bdd.js +99 -13
- package/lib/mocha/cli.js +60 -27
- package/lib/mocha/factory.js +75 -19
- package/lib/mocha/featureConfig.js +1 -1
- package/lib/mocha/gherkin.js +57 -25
- package/lib/mocha/hooks.js +12 -3
- package/lib/mocha/index.js +13 -4
- package/lib/mocha/inject.js +22 -5
- package/lib/mocha/scenarioConfig.js +2 -2
- package/lib/mocha/suite.js +9 -2
- package/lib/mocha/test.js +10 -13
- package/lib/mocha/ui.js +28 -31
- package/lib/output.js +11 -9
- package/lib/parser.js +44 -44
- package/lib/pause.js +15 -16
- package/lib/plugin/analyze.js +19 -12
- package/lib/plugin/auth.js +20 -21
- package/lib/plugin/autoDelay.js +12 -8
- package/lib/plugin/coverage.js +12 -8
- package/lib/plugin/customLocator.js +3 -3
- package/lib/plugin/customReporter.js +3 -2
- package/lib/plugin/heal.js +14 -9
- package/lib/plugin/pageInfo.js +10 -10
- package/lib/plugin/pauseOnFail.js +4 -3
- package/lib/plugin/retryFailedStep.js +47 -5
- package/lib/plugin/screenshotOnFail.js +75 -37
- package/lib/plugin/stepByStepReport.js +14 -14
- package/lib/plugin/stepTimeout.js +4 -3
- package/lib/plugin/subtitles.js +6 -5
- package/lib/recorder.js +33 -23
- package/lib/rerun.js +69 -26
- package/lib/result.js +4 -4
- package/lib/secret.js +18 -17
- package/lib/session.js +95 -89
- package/lib/step/base.js +6 -6
- package/lib/step/config.js +1 -1
- package/lib/step/func.js +3 -3
- package/lib/step/helper.js +3 -3
- package/lib/step/meta.js +4 -4
- package/lib/step/record.js +11 -11
- package/lib/step/retry.js +3 -3
- package/lib/step/section.js +3 -3
- package/lib/step.js +7 -10
- package/lib/steps.js +9 -5
- package/lib/store.js +1 -1
- package/lib/timeout.js +1 -7
- package/lib/transform.js +8 -8
- package/lib/translation.js +32 -18
- package/lib/utils.js +68 -97
- package/lib/workerStorage.js +16 -17
- package/lib/workers.js +145 -171
- package/package.json +63 -57
- package/translations/de-DE.js +2 -2
- package/translations/fr-FR.js +2 -2
- package/translations/index.js +23 -10
- package/translations/it-IT.js +2 -2
- package/translations/ja-JP.js +2 -2
- package/translations/nl-NL.js +2 -2
- package/translations/pl-PL.js +2 -2
- package/translations/pt-BR.js +2 -2
- package/translations/ru-RU.js +2 -2
- package/translations/utils.js +11 -2
- package/translations/zh-CN.js +2 -2
- package/translations/zh-TW.js +2 -2
- package/typings/index.d.ts +7 -18
- package/typings/promiseBasedTypes.d.ts +3769 -5450
- package/typings/types.d.ts +3953 -5778
- package/bin/test-server.js +0 -53
- package/lib/element/WebElement.js +0 -327
- package/lib/helper/Nightmare.js +0 -1486
- package/lib/helper/Protractor.js +0 -1840
- package/lib/helper/TestCafe.js +0 -1391
- package/lib/helper/clientscripts/nightmare.js +0 -213
- package/lib/helper/extras/PlaywrightReactVueLocator.js +0 -43
- package/lib/helper/testcafe/testControllerHolder.js +0 -42
- package/lib/helper/testcafe/testcafe-utils.js +0 -61
- package/lib/listener/retryEnhancer.js +0 -85
- package/lib/plugin/allure.js +0 -15
- package/lib/plugin/autoLogin.js +0 -5
- package/lib/plugin/commentStep.js +0 -141
- package/lib/plugin/eachElement.js +0 -127
- package/lib/plugin/fakerTransform.js +0 -49
- package/lib/plugin/htmlReporter.js +0 -1947
- package/lib/plugin/retryTo.js +0 -16
- package/lib/plugin/selenoid.js +0 -364
- package/lib/plugin/standardActingHelpers.js +0 -6
- package/lib/plugin/tryTo.js +0 -16
- package/lib/plugin/wdio.js +0 -247
- package/lib/test-server.js +0 -323
- package/lib/within.js +0 -90
package/lib/html.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { parse, serialize } from 'parse5'
|
|
2
|
+
import { minify } from 'html-minifier-terser'
|
|
3
3
|
|
|
4
4
|
async function minifyHtml(html) {
|
|
5
5
|
return minify(html, {
|
|
@@ -11,7 +11,7 @@ async function minifyHtml(html) {
|
|
|
11
11
|
removeStyleLinkTypeAttributes: true,
|
|
12
12
|
collapseBooleanAttributes: true,
|
|
13
13
|
useShortDoctype: true,
|
|
14
|
-
})
|
|
14
|
+
})
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const defaultHtmlOpts = {
|
|
@@ -19,240 +19,230 @@ const defaultHtmlOpts = {
|
|
|
19
19
|
textElements: ['label', 'h1', 'h2'],
|
|
20
20
|
allowedAttrs: ['id', 'for', 'class', 'name', 'type', 'value', 'tabindex', 'aria-labelledby', 'aria-label', 'label', 'placeholder', 'title', 'alt', 'src', 'role'],
|
|
21
21
|
allowedRoles: ['button', 'checkbox', 'search', 'textbox', 'tab'],
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
23
|
|
|
24
24
|
function removeNonInteractiveElements(html, opts = {}) {
|
|
25
|
-
opts = { ...defaultHtmlOpts, ...opts }
|
|
26
|
-
const {
|
|
27
|
-
interactiveElements,
|
|
28
|
-
textElements,
|
|
29
|
-
allowedAttrs,
|
|
30
|
-
allowedRoles,
|
|
31
|
-
} = opts;
|
|
25
|
+
opts = { ...defaultHtmlOpts, ...opts }
|
|
26
|
+
const { interactiveElements, textElements, allowedAttrs, allowedRoles } = opts
|
|
32
27
|
|
|
33
28
|
// Parse the HTML into a document tree
|
|
34
|
-
const document = parse(html)
|
|
29
|
+
const document = parse(html)
|
|
35
30
|
|
|
36
|
-
const trashHtmlClasses = /^(text-|color-|flex-|float-|v-|ember-|d-|border-)
|
|
31
|
+
const trashHtmlClasses = /^(text-|color-|flex-|float-|v-|ember-|d-|border-)/
|
|
37
32
|
// Array to store interactive elements
|
|
38
|
-
const removeElements = ['path', 'script']
|
|
33
|
+
const removeElements = ['path', 'script']
|
|
39
34
|
|
|
40
35
|
function isFilteredOut(node) {
|
|
41
|
-
if (removeElements.includes(node.nodeName)) return true
|
|
36
|
+
if (removeElements.includes(node.nodeName)) return true
|
|
42
37
|
if (node.attrs) {
|
|
43
|
-
if (node.attrs.find(attr => attr.name === 'role' && attr.value === 'tooltip')) return true
|
|
38
|
+
if (node.attrs.find(attr => attr.name === 'role' && attr.value === 'tooltip')) return true
|
|
44
39
|
}
|
|
45
|
-
return false
|
|
40
|
+
return false
|
|
46
41
|
}
|
|
47
42
|
|
|
48
43
|
// Function to check if an element is interactive
|
|
49
44
|
function isInteractive(element) {
|
|
50
|
-
if (element.nodeName === 'input' && element.attrs.find(attr => attr.name === 'type' && attr.value === 'hidden')) return false
|
|
51
|
-
if (interactiveElements.includes(element.nodeName)) return true
|
|
45
|
+
if (element.nodeName === 'input' && element.attrs.find(attr => attr.name === 'type' && attr.value === 'hidden')) return false
|
|
46
|
+
if (interactiveElements.includes(element.nodeName)) return true
|
|
52
47
|
if (element.attrs) {
|
|
53
|
-
if (element.attrs.find(attr => attr.name === 'contenteditable')) return true
|
|
54
|
-
if (element.attrs.find(attr => attr.name === 'tabindex')) return true
|
|
55
|
-
const role = element.attrs.find(attr => attr.name === 'role')
|
|
56
|
-
if (role && allowedRoles.includes(role.value)) return true
|
|
48
|
+
if (element.attrs.find(attr => attr.name === 'contenteditable')) return true
|
|
49
|
+
if (element.attrs.find(attr => attr.name === 'tabindex')) return true
|
|
50
|
+
const role = element.attrs.find(attr => attr.name === 'role')
|
|
51
|
+
if (role && allowedRoles.includes(role.value)) return true
|
|
57
52
|
}
|
|
58
|
-
return false
|
|
53
|
+
return false
|
|
59
54
|
}
|
|
60
55
|
|
|
61
56
|
function hasMeaningfulText(node) {
|
|
62
|
-
if (textElements.includes(node.nodeName)) return true
|
|
63
|
-
return false
|
|
57
|
+
if (textElements.includes(node.nodeName)) return true
|
|
58
|
+
return false
|
|
64
59
|
}
|
|
65
60
|
|
|
66
61
|
function hasInteractiveDescendant(node) {
|
|
67
|
-
if (!node.childNodes) return false
|
|
68
|
-
let result = false
|
|
62
|
+
if (!node.childNodes) return false
|
|
63
|
+
let result = false
|
|
69
64
|
|
|
70
65
|
for (const childNode of node.childNodes) {
|
|
71
|
-
if (isInteractive(childNode) || hasMeaningfulText(childNode)) return true
|
|
72
|
-
result = result || hasInteractiveDescendant(childNode)
|
|
66
|
+
if (isInteractive(childNode) || hasMeaningfulText(childNode)) return true
|
|
67
|
+
result = result || hasInteractiveDescendant(childNode)
|
|
73
68
|
}
|
|
74
69
|
|
|
75
|
-
return result
|
|
70
|
+
return result
|
|
76
71
|
}
|
|
77
72
|
|
|
78
73
|
// Function to remove non-interactive elements recursively
|
|
79
74
|
function removeNonInteractive(node) {
|
|
80
75
|
if (node.nodeName !== '#document') {
|
|
81
|
-
const parent = node.parentNode
|
|
82
|
-
const index = parent.childNodes.indexOf(node)
|
|
76
|
+
const parent = node.parentNode
|
|
77
|
+
const index = parent.childNodes.indexOf(node)
|
|
83
78
|
|
|
84
79
|
if (isFilteredOut(node)) {
|
|
85
|
-
parent.childNodes.splice(index, 1)
|
|
86
|
-
return true
|
|
80
|
+
parent.childNodes.splice(index, 1)
|
|
81
|
+
return true
|
|
87
82
|
}
|
|
88
83
|
|
|
89
84
|
// keep texts for interactive elements
|
|
90
85
|
if ((isInteractive(parent) || hasMeaningfulText(parent)) && node.nodeName === '#text') {
|
|
91
|
-
node.value = node.value.trim().slice(0, 200)
|
|
92
|
-
if (!node.value) return false
|
|
93
|
-
return true
|
|
86
|
+
node.value = node.value.trim().slice(0, 200)
|
|
87
|
+
if (!node.value) return false
|
|
88
|
+
return true
|
|
94
89
|
}
|
|
95
90
|
|
|
96
91
|
if (
|
|
97
92
|
// if parent is interactive, we may need child element to match
|
|
98
|
-
!isInteractive(parent)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
!isInteractive(parent) &&
|
|
94
|
+
!isInteractive(node) &&
|
|
95
|
+
!hasInteractiveDescendant(node) &&
|
|
96
|
+
!hasMeaningfulText(node)
|
|
97
|
+
) {
|
|
98
|
+
parent.childNodes.splice(index, 1)
|
|
99
|
+
return true
|
|
104
100
|
}
|
|
105
101
|
}
|
|
106
102
|
|
|
107
103
|
if (node.attrs) {
|
|
108
104
|
// Filter and keep allowed attributes, accessibility attributes
|
|
109
105
|
node.attrs = node.attrs.filter(attr => {
|
|
110
|
-
const { name, value } = attr
|
|
106
|
+
const { name, value } = attr
|
|
111
107
|
if (name === 'class') {
|
|
112
108
|
// Remove classes containing digits
|
|
113
|
-
attr.value = value
|
|
109
|
+
attr.value = value
|
|
110
|
+
.split(' ')
|
|
114
111
|
// remove classes containing digits/
|
|
115
112
|
.filter(className => !/\d/.test(className))
|
|
116
113
|
// remove popular trash classes
|
|
117
114
|
.filter(className => !className.match(trashHtmlClasses))
|
|
118
115
|
// remove classes with : and __ in them
|
|
119
116
|
.filter(className => !className.match(/(:|__)/))
|
|
120
|
-
.join(' ')
|
|
117
|
+
.join(' ')
|
|
121
118
|
}
|
|
122
119
|
|
|
123
|
-
return allowedAttrs.includes(name)
|
|
124
|
-
})
|
|
120
|
+
return allowedAttrs.includes(name)
|
|
121
|
+
})
|
|
125
122
|
}
|
|
126
123
|
|
|
127
124
|
if (node.childNodes) {
|
|
128
125
|
for (let i = node.childNodes.length - 1; i >= 0; i--) {
|
|
129
|
-
const childNode = node.childNodes[i]
|
|
130
|
-
removeNonInteractive(childNode)
|
|
126
|
+
const childNode = node.childNodes[i]
|
|
127
|
+
removeNonInteractive(childNode)
|
|
131
128
|
}
|
|
132
129
|
}
|
|
133
|
-
return false
|
|
130
|
+
return false
|
|
134
131
|
}
|
|
135
132
|
|
|
136
133
|
// Remove non-interactive elements starting from the root element
|
|
137
|
-
removeNonInteractive(document)
|
|
134
|
+
removeNonInteractive(document)
|
|
138
135
|
|
|
139
136
|
// Serialize the modified document tree back to HTML
|
|
140
|
-
const serializedHTML = serialize(document)
|
|
137
|
+
const serializedHTML = serialize(document)
|
|
141
138
|
|
|
142
|
-
return serializedHTML
|
|
139
|
+
return serializedHTML
|
|
143
140
|
}
|
|
144
141
|
|
|
145
142
|
function scanForErrorMessages(html, errorClasses = []) {
|
|
146
143
|
// Parse the HTML into a document tree
|
|
147
|
-
const document = parse(html)
|
|
144
|
+
const document = parse(html)
|
|
148
145
|
|
|
149
146
|
// Array to store error messages
|
|
150
|
-
const errorMessages = []
|
|
147
|
+
const errorMessages = []
|
|
151
148
|
|
|
152
149
|
// Function to recursively scan for error classes and messages
|
|
153
150
|
function scanErrors(node) {
|
|
154
151
|
if (node.attrs) {
|
|
155
|
-
const classAttr = node.attrs.find(attr => attr.name === 'class')
|
|
152
|
+
const classAttr = node.attrs.find(attr => attr.name === 'class')
|
|
156
153
|
if (classAttr && classAttr.value) {
|
|
157
|
-
const classNameChunks = classAttr.value.split(' ')
|
|
158
|
-
const errorClassFound = errorClasses.some(errorClass => classNameChunks.includes(errorClass))
|
|
154
|
+
const classNameChunks = classAttr.value.split(' ')
|
|
155
|
+
const errorClassFound = errorClasses.some(errorClass => classNameChunks.includes(errorClass))
|
|
159
156
|
if (errorClassFound && node.childNodes) {
|
|
160
|
-
const errorMessage = sanitizeTextContent(node)
|
|
161
|
-
errorMessages.push(errorMessage)
|
|
157
|
+
const errorMessage = sanitizeTextContent(node)
|
|
158
|
+
errorMessages.push(errorMessage)
|
|
162
159
|
}
|
|
163
160
|
}
|
|
164
161
|
}
|
|
165
162
|
|
|
166
163
|
if (node.childNodes) {
|
|
167
164
|
for (const childNode of node.childNodes) {
|
|
168
|
-
scanErrors(childNode)
|
|
165
|
+
scanErrors(childNode)
|
|
169
166
|
}
|
|
170
167
|
}
|
|
171
168
|
}
|
|
172
169
|
|
|
173
170
|
// Start scanning for error classes and messages from the root element
|
|
174
|
-
scanErrors(document)
|
|
171
|
+
scanErrors(document)
|
|
175
172
|
|
|
176
|
-
return errorMessages
|
|
173
|
+
return errorMessages
|
|
177
174
|
}
|
|
178
175
|
|
|
179
176
|
function sanitizeTextContent(node) {
|
|
180
177
|
if (node.nodeName === '#text') {
|
|
181
|
-
return node.value.trim()
|
|
178
|
+
return node.value.trim()
|
|
182
179
|
}
|
|
183
180
|
|
|
184
|
-
let sanitizedText = ''
|
|
181
|
+
let sanitizedText = ''
|
|
185
182
|
|
|
186
183
|
if (node.childNodes) {
|
|
187
184
|
for (const childNode of node.childNodes) {
|
|
188
|
-
sanitizedText += sanitizeTextContent(childNode)
|
|
185
|
+
sanitizedText += sanitizeTextContent(childNode)
|
|
189
186
|
}
|
|
190
187
|
}
|
|
191
188
|
|
|
192
|
-
return sanitizedText
|
|
189
|
+
return sanitizedText
|
|
193
190
|
}
|
|
194
191
|
|
|
195
192
|
function buildPath(node, path = '') {
|
|
196
|
-
const tag = node.nodeName
|
|
197
|
-
let attributes = ''
|
|
193
|
+
const tag = node.nodeName
|
|
194
|
+
let attributes = ''
|
|
198
195
|
|
|
199
196
|
if (node.attrs) {
|
|
200
|
-
attributes = node.attrs
|
|
201
|
-
.map(attr => `${attr.name}="${attr.value}"`)
|
|
202
|
-
.join(' ');
|
|
197
|
+
attributes = node.attrs.map(attr => `${attr.name}="${attr.value}"`).join(' ')
|
|
203
198
|
}
|
|
204
199
|
|
|
205
200
|
if (!tag.startsWith('#') && tag !== 'body' && tag !== 'html') {
|
|
206
|
-
path += `<${node.nodeName}${node.attrs ? ` ${attributes}` : ''}
|
|
201
|
+
path += `<${node.nodeName}${node.attrs ? ` ${attributes}` : ''}>`
|
|
207
202
|
}
|
|
208
203
|
|
|
209
|
-
if (!node.childNodes) return path
|
|
204
|
+
if (!node.childNodes) return path
|
|
210
205
|
|
|
211
|
-
const children = node.childNodes.filter(child => !child.nodeName.startsWith('#'))
|
|
206
|
+
const children = node.childNodes.filter(child => !child.nodeName.startsWith('#'))
|
|
212
207
|
|
|
213
208
|
if (children.length) {
|
|
214
|
-
return buildPath(children[children.length - 1], path)
|
|
209
|
+
return buildPath(children[children.length - 1], path)
|
|
215
210
|
}
|
|
216
|
-
return path
|
|
211
|
+
return path
|
|
217
212
|
}
|
|
218
213
|
|
|
219
214
|
function splitByChunks(text, chunkSize) {
|
|
220
|
-
chunkSize -= 20
|
|
221
|
-
const chunks = []
|
|
215
|
+
chunkSize -= 20
|
|
216
|
+
const chunks = []
|
|
222
217
|
for (let i = 0; i < text.length; i += chunkSize) {
|
|
223
|
-
chunks.push(text.slice(i, i + chunkSize))
|
|
218
|
+
chunks.push(text.slice(i, i + chunkSize))
|
|
224
219
|
}
|
|
225
220
|
|
|
226
|
-
const regex = /<\s*\w+(?:\s+\w+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+)))*\s
|
|
221
|
+
const regex = /<\s*\w+(?:\s+\w+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+)))*\s*$/
|
|
227
222
|
|
|
228
223
|
// append tag to chunk if it was split out
|
|
229
224
|
for (const index in chunks) {
|
|
230
|
-
const nextIndex = parseInt(index, 10) + 1
|
|
231
|
-
if (!chunks[nextIndex]) break
|
|
225
|
+
const nextIndex = parseInt(index, 10) + 1
|
|
226
|
+
if (!chunks[nextIndex]) break
|
|
232
227
|
|
|
233
|
-
const currentChunk = chunks[index]
|
|
234
|
-
const nextChunk = chunks[nextIndex]
|
|
228
|
+
const currentChunk = chunks[index]
|
|
229
|
+
const nextChunk = chunks[nextIndex]
|
|
235
230
|
|
|
236
|
-
const lastTag = currentChunk.match(regex)
|
|
231
|
+
const lastTag = currentChunk.match(regex)
|
|
237
232
|
if (lastTag) {
|
|
238
|
-
chunks[nextIndex] = lastTag[0] + nextChunk
|
|
233
|
+
chunks[nextIndex] = lastTag[0] + nextChunk
|
|
239
234
|
}
|
|
240
235
|
|
|
241
|
-
const path = buildPath(parse(currentChunk))
|
|
236
|
+
const path = buildPath(parse(currentChunk))
|
|
242
237
|
if (path) {
|
|
243
|
-
chunks[nextIndex] = path + chunks[nextIndex]
|
|
238
|
+
chunks[nextIndex] = path + chunks[nextIndex]
|
|
244
239
|
}
|
|
245
240
|
|
|
246
|
-
if (chunks[nextIndex].includes('<html')) continue
|
|
247
|
-
chunks[nextIndex] = `<html><body>${chunks[nextIndex]}</body></html
|
|
241
|
+
if (chunks[nextIndex].includes('<html')) continue
|
|
242
|
+
chunks[nextIndex] = `<html><body>${chunks[nextIndex]}</body></html>`
|
|
248
243
|
}
|
|
249
244
|
|
|
250
|
-
return chunks.map(chunk => chunk.trim())
|
|
245
|
+
return chunks.map(chunk => chunk.trim())
|
|
251
246
|
}
|
|
252
247
|
|
|
253
|
-
|
|
254
|
-
scanForErrorMessages,
|
|
255
|
-
removeNonInteractiveElements,
|
|
256
|
-
splitByChunks,
|
|
257
|
-
minifyHtml,
|
|
258
|
-
};
|
|
248
|
+
export { scanForErrorMessages, removeNonInteractiveElements, splitByChunks, minifyHtml }
|
package/lib/index.js
CHANGED
|
@@ -5,42 +5,69 @@
|
|
|
5
5
|
* @alias index
|
|
6
6
|
* @namespace
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
import codecept from './codecept.js'
|
|
9
|
+
import output from './output.js'
|
|
10
|
+
import container from './container.js'
|
|
11
|
+
import event from './event.js'
|
|
12
|
+
import recorder from './recorder.js'
|
|
13
|
+
import config from './config.js'
|
|
14
|
+
import actor from './actor.js'
|
|
15
|
+
import helper from './helper.js'
|
|
16
|
+
import pause from './pause.js'
|
|
17
|
+
import { within } from './effects.js'
|
|
18
|
+
import dataTable from './data/table.js'
|
|
19
|
+
import dataTableArgument from './data/dataTableArgument.js'
|
|
20
|
+
import store from './store.js'
|
|
21
|
+
import locator from './locator.js'
|
|
22
|
+
import heal from './heal.js'
|
|
23
|
+
import ai from './ai.js'
|
|
24
|
+
import Workers from './workers.js'
|
|
25
|
+
import Secret, { secret } from './secret.js'
|
|
26
|
+
|
|
27
|
+
export default {
|
|
9
28
|
/** @type {typeof CodeceptJS.Codecept} */
|
|
10
|
-
codecept
|
|
29
|
+
codecept,
|
|
11
30
|
/** @type {typeof CodeceptJS.Codecept} */
|
|
12
|
-
Codecept:
|
|
31
|
+
Codecept: codecept,
|
|
13
32
|
/** @type {typeof CodeceptJS.output} */
|
|
14
|
-
output
|
|
33
|
+
output,
|
|
15
34
|
/** @type {typeof CodeceptJS.Container} */
|
|
16
|
-
container
|
|
35
|
+
container,
|
|
17
36
|
/** @type {typeof CodeceptJS.event} */
|
|
18
|
-
event
|
|
37
|
+
event,
|
|
19
38
|
/** @type {CodeceptJS.recorder} */
|
|
20
|
-
recorder
|
|
39
|
+
recorder,
|
|
21
40
|
/** @type {typeof CodeceptJS.Config} */
|
|
22
|
-
config
|
|
41
|
+
config,
|
|
23
42
|
/** @type {CodeceptJS.actor} */
|
|
24
|
-
actor
|
|
43
|
+
actor,
|
|
25
44
|
/** @type {typeof CodeceptJS.Helper} */
|
|
26
|
-
helper
|
|
45
|
+
helper,
|
|
27
46
|
/** @type {typeof CodeceptJS.Helper} */
|
|
28
|
-
Helper:
|
|
47
|
+
Helper: helper,
|
|
29
48
|
/** @type {typeof CodeceptJS.pause} */
|
|
30
|
-
pause
|
|
49
|
+
pause,
|
|
31
50
|
/** @type {typeof CodeceptJS.within} */
|
|
32
|
-
within
|
|
51
|
+
within,
|
|
33
52
|
/** @type {typeof CodeceptJS.DataTable} */
|
|
34
|
-
dataTable
|
|
53
|
+
dataTable,
|
|
35
54
|
/** @type {typeof CodeceptJS.DataTableArgument} */
|
|
36
|
-
dataTableArgument
|
|
55
|
+
dataTableArgument,
|
|
37
56
|
/** @type {typeof CodeceptJS.store} */
|
|
38
|
-
store
|
|
57
|
+
store,
|
|
39
58
|
/** @type {typeof CodeceptJS.Locator} */
|
|
40
|
-
locator
|
|
59
|
+
locator,
|
|
60
|
+
|
|
61
|
+
heal,
|
|
62
|
+
ai,
|
|
63
|
+
|
|
64
|
+
Workers,
|
|
41
65
|
|
|
42
|
-
|
|
43
|
-
|
|
66
|
+
/** @type {typeof CodeceptJS.Secret} */
|
|
67
|
+
Secret,
|
|
68
|
+
/** @type {typeof CodeceptJS.secret} */
|
|
69
|
+
secret,
|
|
70
|
+
}
|
|
44
71
|
|
|
45
|
-
|
|
46
|
-
}
|
|
72
|
+
// Named exports for ESM compatibility
|
|
73
|
+
export { codecept, output, container, event, recorder, config, actor, helper, pause, within, dataTable, dataTableArgument, store, locator, heal, ai, Workers, Secret, secret }
|
package/lib/listener/config.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { debug } = require('../output')
|
|
1
|
+
import event from '../event.js'
|
|
2
|
+
import recorder from '../recorder.js'
|
|
3
|
+
import { deepMerge, deepClone, ucfirst } from '../utils.js'
|
|
4
|
+
import output from '../output.js'
|
|
6
5
|
/**
|
|
7
6
|
* Enable Helpers to listen to test events
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
const helpers = container.helpers()
|
|
8
|
+
export default function () {
|
|
9
|
+
const helpers = global.container.helpers()
|
|
11
10
|
|
|
12
11
|
enableDynamicConfigFor('suite')
|
|
13
12
|
enableDynamicConfigFor('test')
|
|
@@ -18,14 +17,14 @@ module.exports = function () {
|
|
|
18
17
|
const oldConfig = { ...helper.options }
|
|
19
18
|
try {
|
|
20
19
|
helper._setConfig(deepMerge(deepClone(oldConfig), config))
|
|
21
|
-
debug(`[${ucfirst(type)} Config] ${helper.constructor.name} ${JSON.stringify(config)}`)
|
|
20
|
+
output.debug(`[${ucfirst(type)} Config] ${helper.constructor.name} ${JSON.stringify(config)}`)
|
|
22
21
|
} catch (err) {
|
|
23
22
|
recorder.throw(err)
|
|
24
23
|
return
|
|
25
24
|
}
|
|
26
25
|
event.dispatcher.once(event[type].after, () => {
|
|
27
26
|
helper._setConfig(oldConfig)
|
|
28
|
-
debug(`[${ucfirst(type)} Config] Reverted for ${helper.constructor.name}`)
|
|
27
|
+
output.debug(`[${ucfirst(type)} Config] Reverted for ${helper.constructor.name}`)
|
|
29
28
|
})
|
|
30
29
|
}
|
|
31
30
|
|
package/lib/listener/emptyRun.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { searchWithFusejs } = require('../utils')
|
|
1
|
+
import figures from 'figures'
|
|
2
|
+
import event from '../event.js'
|
|
3
|
+
import output from '../output.js'
|
|
4
|
+
import { searchWithFusejs } from '../utils.js'
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
export default function () {
|
|
8
7
|
let isEmptyRun = true
|
|
9
8
|
|
|
10
9
|
event.dispatcher.on(event.test.before, test => {
|
|
@@ -13,7 +12,7 @@ module.exports = function () {
|
|
|
13
12
|
|
|
14
13
|
event.dispatcher.on(event.all.result, () => {
|
|
15
14
|
if (isEmptyRun) {
|
|
16
|
-
const mocha =
|
|
15
|
+
const mocha = global.container.mocha()
|
|
17
16
|
|
|
18
17
|
if (mocha.options.grep) {
|
|
19
18
|
output.print()
|
package/lib/listener/exit.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import event from '../event.js'
|
|
2
|
+
import debugModule from 'debug'
|
|
3
|
+
const debug = debugModule('codeceptjs:exit')
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
export default function () {
|
|
5
6
|
let failedTests = []
|
|
6
7
|
|
|
7
8
|
event.dispatcher.on(event.test.failed, test => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import event from '../event.js'
|
|
2
|
+
import output from '../output.js'
|
|
3
|
+
import Config from '../config.js'
|
|
4
|
+
import { isNotSet } from '../utils.js'
|
|
5
5
|
|
|
6
6
|
const hooks = ['Before', 'After', 'BeforeSuite', 'AfterSuite']
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export default function () {
|
|
9
9
|
event.dispatcher.on(event.suite.before, suite => {
|
|
10
10
|
let retryConfig = Config.get('retry')
|
|
11
11
|
if (!retryConfig) return
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import event from '../event.js'
|
|
2
|
+
import output from '../output.js'
|
|
3
|
+
import recorder from '../recorder.js'
|
|
4
|
+
import Config from '../config.js'
|
|
5
|
+
import store from '../store.js'
|
|
6
|
+
import debugModule from 'debug'
|
|
7
|
+
const debug = debugModule('codeceptjs:timeout')
|
|
8
|
+
import { TIMEOUT_ORDER, TimeoutError, TestTimeoutError, StepTimeoutError } from '../timeout.js'
|
|
9
|
+
import { BeforeSuiteHook, AfterSuiteHook } from '../mocha/hooks.js'
|
|
10
|
+
|
|
11
|
+
export default function () {
|
|
11
12
|
let timeout
|
|
12
13
|
let suiteTimeout = []
|
|
13
14
|
let currentTest
|
package/lib/listener/helpers.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { error } = require('../output')
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import event from '../event.js'
|
|
3
|
+
import recorder from '../recorder.js'
|
|
4
|
+
import store from '../store.js'
|
|
5
|
+
import output from '../output.js'
|
|
7
6
|
/**
|
|
8
7
|
* Enable Helpers to listen to test events
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
const helpers = container.helpers()
|
|
9
|
+
export default function () {
|
|
10
|
+
const helpers = global.container.helpers()
|
|
12
11
|
|
|
13
12
|
const runHelpersHook = (hook, param) => {
|
|
14
13
|
if (store.dryRun) return
|
|
@@ -39,30 +38,30 @@ module.exports = function () {
|
|
|
39
38
|
|
|
40
39
|
event.dispatcher.on(event.test.started, test => {
|
|
41
40
|
runHelpersHook('_test', test)
|
|
42
|
-
recorder.catch(e => error(e))
|
|
41
|
+
recorder.catch(e => output.error(e))
|
|
43
42
|
})
|
|
44
43
|
|
|
45
44
|
event.dispatcher.on(event.test.before, test => {
|
|
46
45
|
// schedule config to revert changes
|
|
47
46
|
runAsyncHelpersHook('_before', test, true)
|
|
48
|
-
recorder.catchWithoutStop(e => error(e))
|
|
47
|
+
recorder.catchWithoutStop(e => output.error(e))
|
|
49
48
|
})
|
|
50
49
|
|
|
51
50
|
event.dispatcher.on(event.test.passed, test => {
|
|
52
51
|
runAsyncHelpersHook('_passed', test, true)
|
|
53
52
|
// should not fail test execution, so errors should be caught
|
|
54
|
-
recorder.catchWithoutStop(e => error(e))
|
|
53
|
+
recorder.catchWithoutStop(e => output.error(e))
|
|
55
54
|
})
|
|
56
55
|
|
|
57
56
|
event.dispatcher.on(event.test.failed, test => {
|
|
58
57
|
runAsyncHelpersHook('_failed', test, true)
|
|
59
58
|
// should not fail test execution, so errors should be caught
|
|
60
|
-
recorder.catchWithoutStop(e => error(e))
|
|
59
|
+
recorder.catchWithoutStop(e => output.error(e))
|
|
61
60
|
})
|
|
62
61
|
|
|
63
62
|
event.dispatcher.on(event.test.after, () => {
|
|
64
63
|
runAsyncHelpersHook('_after', {}, true)
|
|
65
|
-
recorder.catchWithoutStop(e => error(e))
|
|
64
|
+
recorder.catchWithoutStop(e => output.error(e))
|
|
66
65
|
})
|
|
67
66
|
|
|
68
67
|
event.dispatcher.on(event.step.before, step => {
|
|
@@ -74,6 +73,26 @@ module.exports = function () {
|
|
|
74
73
|
})
|
|
75
74
|
|
|
76
75
|
event.dispatcher.on(event.all.result, () => {
|
|
77
|
-
|
|
76
|
+
// Skip _finishTest for all helpers if any browser helper restarts to avoid double cleanup
|
|
77
|
+
const hasBrowserRestart = Object.values(helpers).some(helper => (helper.config && helper.config.restart) || (helper.options && helper.options.restart === 'context'))
|
|
78
|
+
|
|
79
|
+
Object.keys(helpers).forEach(key => {
|
|
80
|
+
const helper = helpers[key]
|
|
81
|
+
if (helper._finishTest && !hasBrowserRestart) {
|
|
82
|
+
recorder.add(`hook ${key}._finishTest()`, () => helper._finishTest(), true, false)
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
event.dispatcher.on(event.all.after, () => {
|
|
88
|
+
// Skip _cleanup for all helpers if any browser helper restarts to avoid double cleanup
|
|
89
|
+
const hasBrowserRestart = Object.values(helpers).some(helper => (helper.config && helper.config.restart) || (helper.options && helper.options.restart === 'context'))
|
|
90
|
+
|
|
91
|
+
Object.keys(helpers).forEach(key => {
|
|
92
|
+
const helper = helpers[key]
|
|
93
|
+
if (helper._cleanup && !hasBrowserRestart) {
|
|
94
|
+
recorder.add(`hook ${key}._cleanup()`, () => helper._cleanup(), true, false)
|
|
95
|
+
}
|
|
96
|
+
})
|
|
78
97
|
})
|
|
79
98
|
}
|
package/lib/listener/mocha.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
const container = require('../container')
|
|
1
|
+
import event from '../event.js'
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
export default function () {
|
|
5
4
|
let mocha
|
|
6
5
|
|
|
7
6
|
event.dispatcher.on(event.all.before, () => {
|
|
8
|
-
mocha = container.mocha()
|
|
7
|
+
mocha = global.container.mocha()
|
|
9
8
|
})
|
|
10
9
|
|
|
11
10
|
event.dispatcher.on(event.test.passed, test => {
|