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
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
const output = require('../output')
|
|
2
|
-
const store = require('../store')
|
|
3
|
-
const recorder = require('../recorder')
|
|
4
|
-
const container = require('../container')
|
|
5
|
-
const event = require('../event')
|
|
6
|
-
const Step = require('../step')
|
|
7
|
-
const { isAsyncFunction } = require('../utils')
|
|
8
|
-
|
|
9
|
-
const defaultConfig = {
|
|
10
|
-
registerGlobal: true,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Provides `eachElement` global function to iterate over found elements to perform actions on them.
|
|
15
|
-
*
|
|
16
|
-
* `eachElement` takes following args:
|
|
17
|
-
* * `purpose` - the goal of an action. A comment text that will be displayed in output.
|
|
18
|
-
* * `locator` - a CSS/XPath locator to match elements
|
|
19
|
-
* * `fn(element, index)` - **asynchronous** function which will be executed for each matched element.
|
|
20
|
-
*
|
|
21
|
-
* Example of usage:
|
|
22
|
-
*
|
|
23
|
-
* ```js
|
|
24
|
-
* // this example works with Playwright and Puppeteer helper
|
|
25
|
-
* await eachElement('click all checkboxes', 'form input[type=checkbox]', async (el) => {
|
|
26
|
-
* await el.click();
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
29
|
-
* Click odd elements:
|
|
30
|
-
*
|
|
31
|
-
* ```js
|
|
32
|
-
* // this example works with Playwright and Puppeteer helper
|
|
33
|
-
* await eachElement('click odd buttons', '.button-select', async (el, index) => {
|
|
34
|
-
* if (index % 2) await el.click();
|
|
35
|
-
* });
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* Check all elements for visibility:
|
|
39
|
-
*
|
|
40
|
-
* ```js
|
|
41
|
-
* // this example works with Playwright and Puppeteer helper
|
|
42
|
-
* const assert = require('assert');
|
|
43
|
-
* await eachElement('check all items are visible', '.item', async (el) => {
|
|
44
|
-
* assert(await el.isVisible());
|
|
45
|
-
* });
|
|
46
|
-
* ```
|
|
47
|
-
* This method works with WebDriver, Playwright, Puppeteer, Appium helpers.
|
|
48
|
-
*
|
|
49
|
-
* Function parameter `el` represents a matched element.
|
|
50
|
-
* Depending on a helper API of `el` can be different. Refer to API of corresponding browser testing engine for a complete API list:
|
|
51
|
-
*
|
|
52
|
-
* * [Playwright ElementHandle](https://playwright.dev/docs/api/class-elementhandle)
|
|
53
|
-
* * [Puppeteer](https://pptr.dev/#?product=Puppeteer&show=api-class-elementhandle)
|
|
54
|
-
* * [webdriverio element](https://webdriver.io/docs/api)
|
|
55
|
-
*
|
|
56
|
-
* #### Configuration
|
|
57
|
-
*
|
|
58
|
-
* * `registerGlobal` - to register `eachElement` function globally, true by default
|
|
59
|
-
*
|
|
60
|
-
* If `registerGlobal` is false you can use eachElement from the plugin:
|
|
61
|
-
*
|
|
62
|
-
* ```js
|
|
63
|
-
* const eachElement = codeceptjs.container.plugins('eachElement');
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
* @param {string} purpose
|
|
67
|
-
* @param {CodeceptJS.LocatorOrString} locator
|
|
68
|
-
* @param {Function} fn
|
|
69
|
-
* @return {Promise<*> | undefined}
|
|
70
|
-
*/
|
|
71
|
-
function eachElement(purpose, locator, fn) {
|
|
72
|
-
if (store.dryRun) return
|
|
73
|
-
const helpers = Object.values(container.helpers())
|
|
74
|
-
|
|
75
|
-
const helper = helpers.filter(h => !!h._locate)[0]
|
|
76
|
-
|
|
77
|
-
if (!helper) {
|
|
78
|
-
throw new Error('No helper enabled with _locate method with returns a list of elements.')
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (!isAsyncFunction(fn)) {
|
|
82
|
-
throw new Error('Async function should be passed into each element')
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const step = new Step(helper, `${purpose || 'each element'} within "${locator}"`)
|
|
86
|
-
step.helperMethod = '_locate'
|
|
87
|
-
// eachElement('select all users', 'locator', async (el) => {
|
|
88
|
-
event.dispatcher.emit(event.step.before, step)
|
|
89
|
-
|
|
90
|
-
return recorder.add('register each element wrapper', async () => {
|
|
91
|
-
event.emit(event.step.started, step)
|
|
92
|
-
const els = await helper._locate(locator)
|
|
93
|
-
output.debug(`Found ${els.length} elements for each elements to iterate`)
|
|
94
|
-
|
|
95
|
-
const errs = []
|
|
96
|
-
let i = 0
|
|
97
|
-
for (const el of els) {
|
|
98
|
-
try {
|
|
99
|
-
await fn(el, i)
|
|
100
|
-
} catch (err) {
|
|
101
|
-
output.error(`eachElement: failed operation on element #${i} ${el}`)
|
|
102
|
-
errs.push(err)
|
|
103
|
-
}
|
|
104
|
-
i++
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (errs.length) {
|
|
108
|
-
event.dispatcher.emit(event.step.after, step)
|
|
109
|
-
event.emit(event.step.failed, step, errs[0])
|
|
110
|
-
event.emit(event.step.finished, step)
|
|
111
|
-
throw errs[0]
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
event.dispatcher.emit(event.step.after, step)
|
|
115
|
-
event.emit(event.step.passed, step, null)
|
|
116
|
-
event.emit(event.step.finished, step)
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
module.exports = function (config) {
|
|
121
|
-
config = Object.assign(defaultConfig, config)
|
|
122
|
-
|
|
123
|
-
if (config.registerGlobal) {
|
|
124
|
-
global.eachElement = eachElement
|
|
125
|
-
}
|
|
126
|
-
return eachElement
|
|
127
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const { faker } = require('@faker-js/faker')
|
|
2
|
-
const transform = require('../transform')
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Use the `@faker-js/faker` package to generate fake data inside examples on your gherkin tests
|
|
6
|
-
*
|
|
7
|
-
* #### Usage
|
|
8
|
-
*
|
|
9
|
-
* To start please install `@faker-js/faker` package
|
|
10
|
-
*
|
|
11
|
-
* ```
|
|
12
|
-
* npm install -D @faker-js/faker
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* ```
|
|
16
|
-
* yarn add -D @faker-js/faker
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* Add this plugin to config file:
|
|
20
|
-
*
|
|
21
|
-
* ```js
|
|
22
|
-
* plugins: {
|
|
23
|
-
* fakerTransform: {
|
|
24
|
-
* enabled: true
|
|
25
|
-
* }
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* Add the faker API using a mustache string format inside examples tables in your gherkin scenario outline
|
|
30
|
-
*
|
|
31
|
-
* ```feature
|
|
32
|
-
* Scenario Outline: ...
|
|
33
|
-
* Given ...
|
|
34
|
-
* When ...
|
|
35
|
-
* Then ...
|
|
36
|
-
* Examples:
|
|
37
|
-
* | productName | customer | email | anythingMore |
|
|
38
|
-
* | {{commerce.product}} | Dr. {{name.findName}} | {{internet.email}} | staticData |
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
*/
|
|
42
|
-
module.exports = function (config) {
|
|
43
|
-
transform.addTransformerBeforeAll('gherkin.examples', value => {
|
|
44
|
-
if (typeof value === 'string' && value.length > 0) {
|
|
45
|
-
return faker.helpers.fake(value)
|
|
46
|
-
}
|
|
47
|
-
return value
|
|
48
|
-
})
|
|
49
|
-
}
|