codeceptjs 2.3.4 → 2.4.1
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 +52 -0
- package/README.md +28 -6
- package/bin/codecept.js +42 -0
- package/docs/advanced.md +45 -1
- package/docs/angular.md +3 -3
- package/docs/basics.md +162 -118
- package/docs/bdd.md +30 -5
- package/docs/best.md +8 -6
- package/docs/books.md +6 -1
- package/docs/build/Appium.js +95 -85
- package/docs/build/FileSystem.js +48 -3
- package/docs/build/GraphQL.js +3 -2
- package/docs/build/GraphQLDataFactory.js +1 -0
- package/docs/build/Mochawesome.js +3 -2
- package/docs/build/MockRequest.js +23 -5
- package/docs/build/Nightmare.js +87 -128
- package/docs/build/Protractor.js +107 -155
- package/docs/build/Puppeteer.js +190 -174
- package/docs/build/REST.js +13 -9
- package/docs/build/SeleniumWebdriver.js +0 -17
- package/docs/build/TestCafe.js +164 -158
- package/docs/build/WebDriver.js +236 -211
- package/docs/build/WebDriverIO.js +218 -187
- package/docs/changelog.md +57 -1
- package/docs/commands.md +41 -2
- package/docs/community-helpers.md +12 -1
- package/docs/configuration.md +5 -2
- package/docs/continuous-integration.md +22 -0
- package/docs/{helpers.md → custom-helpers.md} +16 -10
- package/docs/data.md +7 -6
- package/docs/detox.md +6 -6
- package/docs/email.md +4 -2
- package/docs/examples.md +22 -3
- package/docs/helpers/ApiDataFactory.md +15 -13
- package/docs/helpers/Appium.md +1011 -468
- package/docs/helpers/Detox.md +33 -26
- package/docs/helpers/FileSystem.md +43 -13
- package/docs/helpers/GraphQL.md +17 -15
- package/docs/helpers/GraphQLDataFactory.md +15 -13
- package/docs/helpers/Mochawesome.md +3 -1
- package/docs/helpers/MockRequest.md +37 -19
- package/docs/helpers/Nightmare.md +129 -240
- package/docs/helpers/Polly.md +1 -1
- package/docs/helpers/Protractor.md +157 -298
- package/docs/helpers/Puppeteer.md +216 -335
- package/docs/helpers/REST.md +29 -24
- package/docs/helpers/TestCafe.md +137 -235
- package/docs/helpers/WebDriver.md +250 -347
- package/docs/hooks.md +14 -10
- package/docs/index.md +112 -0
- package/docs/installation.md +3 -1
- package/docs/locators.md +19 -8
- package/docs/mobile-react-native-locators.md +2 -2
- package/docs/mobile.md +5 -3
- package/docs/nightmare.md +2 -1
- package/docs/pageobjects.md +4 -2
- package/docs/parallel.md +4 -2
- package/docs/plugins.md +41 -15
- package/docs/puppeteer.md +8 -6
- package/docs/quickstart.md +130 -0
- package/docs/react.md +4 -2
- package/docs/reports.md +6 -4
- package/docs/testcafe.md +10 -8
- package/docs/translation.md +4 -2
- package/docs/ui.md +56 -0
- package/docs/videos.md +11 -2
- package/docs/visual.md +7 -5
- package/docs/vue.md +121 -0
- package/docs/webapi/appendField.mustache +1 -1
- package/docs/webapi/attachFile.mustache +1 -1
- package/docs/webapi/checkOption.mustache +2 -2
- package/docs/webapi/clearCookie.mustache +1 -1
- package/docs/webapi/click.mustache +2 -2
- package/docs/webapi/clickLink.mustache +2 -2
- package/docs/webapi/dontSee.mustache +1 -2
- package/docs/webapi/dontSeeCheckboxIsChecked.mustache +1 -1
- package/docs/webapi/dontSeeElement.mustache +1 -1
- package/docs/webapi/dontSeeElementInDOM.mustache +1 -1
- package/docs/webapi/dontSeeInField.mustache +1 -1
- package/docs/webapi/doubleClick.mustache +2 -2
- package/docs/webapi/downloadFile.mustache +1 -1
- package/docs/webapi/dragSlider.mustache +1 -1
- package/docs/webapi/executeAsyncScript.mustache +2 -1
- package/docs/webapi/executeScript.mustache +2 -1
- package/docs/webapi/fillField.mustache +1 -1
- package/docs/webapi/grabAttributeFrom.mustache +1 -1
- package/docs/webapi/grabBrowserLogs.mustache +1 -1
- package/docs/webapi/grabCookie.mustache +2 -2
- package/docs/webapi/grabCssPropertyFrom.mustache +1 -1
- package/docs/webapi/grabHTMLFrom.mustache +1 -1
- package/docs/webapi/grabNumberOfVisibleElements.mustache +1 -1
- package/docs/webapi/grabPageScrollPosition.mustache +1 -1
- package/docs/webapi/grabTextFrom.mustache +2 -2
- package/docs/webapi/grabValueFrom.mustache +1 -1
- package/docs/webapi/moveCursorTo.mustache +3 -3
- package/docs/webapi/pressKey.mustache +1 -1
- package/docs/webapi/pressKeyWithKeyNormalization.mustache +1 -1
- package/docs/webapi/rightClick.mustache +2 -2
- package/docs/webapi/saveScreenshot.mustache +1 -1
- package/docs/webapi/scrollIntoView.mustache +10 -0
- package/docs/webapi/scrollTo.mustache +3 -3
- package/docs/webapi/see.mustache +1 -1
- package/docs/webapi/seeAttributesOnElements.mustache +1 -1
- package/docs/webapi/seeCheckboxIsChecked.mustache +1 -1
- package/docs/webapi/seeCssPropertiesOnElements.mustache +1 -1
- package/docs/webapi/seeElement.mustache +1 -1
- package/docs/webapi/seeElementInDOM.mustache +1 -1
- package/docs/webapi/seeInField.mustache +1 -1
- package/docs/webapi/seeNumberOfElements.mustache +1 -1
- package/docs/webapi/seeNumberOfVisibleElements.mustache +1 -1
- package/docs/webapi/seeTextEquals.mustache +8 -0
- package/docs/webapi/selectOption.mustache +2 -2
- package/docs/webapi/switchTo.mustache +1 -1
- package/docs/webapi/uncheckOption.mustache +2 -2
- package/docs/webapi/waitForClickable.mustache +10 -0
- package/docs/webapi/waitForDetached.mustache +2 -2
- package/docs/webapi/waitForElement.mustache +2 -2
- package/docs/webapi/waitForEnabled.mustache +2 -2
- package/docs/webapi/waitForFunction.mustache +2 -2
- package/docs/webapi/waitForInvisible.mustache +2 -2
- package/docs/webapi/waitForText.mustache +2 -2
- package/docs/webapi/waitForValue.mustache +1 -1
- package/docs/webapi/waitForVisible.mustache +2 -2
- package/docs/webapi/waitInUrl.mustache +1 -1
- package/docs/webapi/waitNumberOfVisibleElements.mustache +2 -2
- package/docs/webapi/waitToHide.mustache +2 -2
- package/docs/webapi/waitUntil.mustache +3 -2
- package/docs/webapi/waitUrlEquals.mustache +1 -1
- package/docs/webdriver.md +20 -18
- package/docs/wiki/.git/FETCH_HEAD +1 -0
- package/docs/wiki/.git/HEAD +1 -0
- package/docs/wiki/.git/ORIG_HEAD +1 -0
- package/docs/wiki/.git/config +11 -0
- package/docs/wiki/.git/description +1 -0
- package/docs/wiki/.git/hooks/applypatch-msg.sample +15 -0
- package/docs/wiki/.git/hooks/commit-msg.sample +24 -0
- package/docs/wiki/.git/hooks/fsmonitor-watchman.sample +114 -0
- package/docs/wiki/.git/hooks/post-update.sample +8 -0
- package/docs/wiki/.git/hooks/pre-applypatch.sample +14 -0
- package/docs/wiki/.git/hooks/pre-commit.sample +49 -0
- package/docs/wiki/.git/hooks/pre-push.sample +53 -0
- package/docs/wiki/.git/hooks/pre-rebase.sample +169 -0
- package/docs/wiki/.git/hooks/pre-receive.sample +24 -0
- package/docs/wiki/.git/hooks/prepare-commit-msg.sample +42 -0
- package/docs/wiki/.git/hooks/update.sample +128 -0
- package/docs/wiki/.git/index +0 -0
- package/docs/wiki/.git/info/exclude +6 -0
- package/docs/wiki/.git/logs/HEAD +4 -0
- package/docs/wiki/.git/logs/refs/heads/master +4 -0
- package/docs/wiki/.git/logs/refs/remotes/origin/HEAD +1 -0
- package/docs/wiki/.git/logs/refs/remotes/origin/master +3 -0
- package/docs/wiki/.git/objects/00/d216b0774d15db2d0a2a0d4ce249b5251acc55 +3 -0
- package/docs/wiki/.git/objects/09/01d87c5241905fdfe3493cfe8f04df4a2685ea +0 -0
- package/docs/wiki/.git/objects/0d/bdd0c20c4deb6a8cc81dbbf32ecf8c09238983 +2 -0
- package/docs/wiki/.git/objects/1a/c29e4fa82422c52392f22f0f2b8d1a759535bf +0 -0
- package/docs/wiki/.git/objects/27/12f92898d3e8f68e229b6cda76570d6c66d781 +0 -0
- package/docs/wiki/.git/objects/2d/dbe22c257166b648928eeb9460ecfb71ba702d +0 -0
- package/docs/wiki/.git/objects/2f/c942ec3773efd2678d9ff98035c61fcded81a1 +0 -0
- package/docs/wiki/.git/objects/40/a2856342c67796b48911a256b764fb06888b94 +5 -0
- package/docs/wiki/.git/objects/47/53181844fc4dc563cf3aa5e80462243cb58d38 +0 -0
- package/docs/wiki/.git/objects/4e/24a95fb2e4f8ffef51f19b694451a205c06f10 +3 -0
- package/docs/wiki/.git/objects/73/31ebd96f3c7e08a9f63f05a25f939afa0d4de1 +0 -0
- package/docs/wiki/.git/objects/86/19cbb2289caa502e33fccf0ed14eecf6ba2ba0 +0 -0
- package/docs/wiki/.git/objects/a4/72f797d9d74b87c9f71a2b1539d75bb07d1e35 +0 -0
- package/docs/wiki/.git/objects/c9/9f3e4bd227d6b050b2e416f9876df49583dbf6 +0 -0
- package/docs/wiki/.git/objects/ca/e609b4ef3e0ef85fcbe0d68d1a58246584b915 +0 -0
- package/docs/wiki/.git/objects/d5/8386ca72f6d550548f3d71d74e3ac73d5ad488 +0 -0
- package/docs/wiki/.git/objects/d9/c6874a6de524bdafeb563a20d847f4fdd59a86 +0 -0
- package/docs/wiki/.git/objects/f1/c944675bb38b40ae553b0be36c14674c79af54 +0 -0
- package/docs/wiki/.git/objects/pack/pack-28da0fc7e6c08d4c5350717bfbb7b1c53e8198ad.idx +0 -0
- package/docs/wiki/.git/objects/pack/pack-28da0fc7e6c08d4c5350717bfbb7b1c53e8198ad.pack +0 -0
- package/docs/wiki/.git/packed-refs +2 -0
- package/docs/wiki/.git/refs/heads/master +1 -0
- package/docs/wiki/.git/refs/remotes/origin/HEAD +1 -0
- package/docs/wiki/.git/refs/remotes/origin/master +1 -0
- package/docs/wiki/Books-&-Posts.md +27 -0
- package/docs/wiki/Community-Helpers.md +41 -0
- package/docs/wiki/Examples.md +138 -0
- package/docs/wiki/Home.md +11 -0
- package/docs/wiki/Release-process.md +25 -0
- package/docs/wiki/Roadmap.md +23 -0
- package/docs/wiki/Videos.md +19 -0
- package/lib/actor.js +18 -1
- package/lib/assert/error.js +3 -3
- package/lib/codecept.js +9 -6
- package/lib/command/configMigrate.js +7 -6
- package/lib/command/definitions.js +98 -350
- package/lib/command/generate.js +22 -17
- package/lib/command/gherkin/init.js +2 -1
- package/lib/command/gherkin/snippets.js +6 -6
- package/lib/command/gherkin/steps.js +0 -1
- package/lib/command/info.js +40 -0
- package/lib/command/init.js +54 -41
- package/lib/command/run-multiple.js +5 -4
- package/lib/command/run-rerun.js +39 -0
- package/lib/command/run-workers.js +4 -6
- package/lib/command/run.js +8 -18
- package/lib/command/utils.js +23 -2
- package/lib/command/workers/runTests.js +1 -2
- package/lib/config.js +10 -4
- package/lib/container.js +31 -6
- package/lib/data/dataTableArgument.js +31 -0
- package/lib/data/table.js +4 -0
- package/lib/event.js +65 -1
- package/lib/helper/Appium.js +52 -38
- package/lib/helper/FileSystem.js +48 -3
- package/lib/helper/GraphQL.js +3 -2
- package/lib/helper/GraphQLDataFactory.js +1 -0
- package/lib/helper/Mochawesome.js +3 -2
- package/lib/helper/MockRequest.js +23 -5
- package/lib/helper/Nightmare.js +5 -6
- package/lib/helper/Protractor.js +7 -8
- package/lib/helper/Puppeteer.js +76 -20
- package/lib/helper/REST.js +13 -9
- package/lib/helper/SeleniumWebdriver.js +0 -17
- package/lib/helper/TestCafe.js +84 -36
- package/lib/helper/WebDriver.js +113 -59
- package/lib/helper/WebDriverIO.js +43 -59
- package/lib/helper/clientscripts/nightmare.js +66 -4
- package/lib/helper/scripts/isElementClickable.js +24 -0
- package/lib/helper.js +34 -10
- package/lib/history.js +1 -1
- package/lib/hooks.js +2 -1
- package/lib/index.js +19 -0
- package/lib/interfaces/bdd.js +4 -0
- package/lib/interfaces/featureConfig.js +10 -3
- package/lib/interfaces/gherkin.js +6 -2
- package/lib/interfaces/scenarioConfig.js +17 -6
- package/lib/listener/config.js +1 -1
- package/lib/listener/exit.js +6 -0
- package/lib/listener/steps.js +0 -1
- package/lib/listener/trace.js +0 -1
- package/lib/locator.js +67 -2
- package/lib/output.js +53 -0
- package/lib/parser.js +2 -71
- package/lib/pause.js +3 -2
- package/lib/plugin/allure.js +41 -22
- package/lib/plugin/autoLogin.js +4 -1
- package/lib/plugin/pauseOnFail.js +38 -0
- package/lib/plugin/puppeteerCoverage.js +8 -7
- package/lib/plugin/screenshotOnFail.js +13 -8
- package/lib/plugin/stepByStepReport.js +7 -6
- package/lib/plugin/wdio.js +2 -1
- package/lib/recorder.js +85 -7
- package/lib/rerun.js +81 -0
- package/lib/secret.js +6 -0
- package/lib/session.js +9 -2
- package/lib/step.js +37 -2
- package/lib/store.js +5 -1
- package/lib/ui.js +34 -8
- package/lib/utils.js +6 -13
- package/lib/within.js +5 -0
- package/package.json +49 -29
- package/typings/Mocha.d.ts +21 -0
- package/typings/Protractor.d.ts +16 -0
- package/typings/index.d.ts +169 -0
- package/typings/jsdoc.conf.js +34 -0
- package/typings/jsdoc.namespace.js +29 -0
- package/typings/types.d.ts +9827 -0
- package/typings/utils.d.ts +7 -0
- package/docs/acceptance.md +0 -409
- package/docs/api/codecept.md +0 -75
- package/docs/api/config.md +0 -49
- package/docs/api/container.md +0 -66
- package/docs/api/helper.md +0 -116
- package/docs/api/output.md +0 -67
- package/docs/api/recorder.md +0 -63
- package/docs/helpers/SeleniumWebdriver.md +0 -92
- package/docs/helpers/WebDriverIO.md +0 -1671
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
if (!window.codeceptjs) {
|
|
2
|
+
/**
|
|
3
|
+
* @alias CodeceptJS.browserCodecept
|
|
4
|
+
* @namespace
|
|
5
|
+
*/
|
|
2
6
|
const codeceptjs = {};
|
|
3
7
|
|
|
4
|
-
|
|
8
|
+
/**
|
|
9
|
+
* all found elements are stored here for reuse
|
|
10
|
+
* @inner
|
|
11
|
+
* @type {Node[]}
|
|
12
|
+
*/
|
|
5
13
|
codeceptjs.elements = [];
|
|
6
14
|
|
|
7
|
-
|
|
15
|
+
/**
|
|
16
|
+
* global context changer
|
|
17
|
+
* @inner
|
|
18
|
+
* @type {?Node}
|
|
19
|
+
*/
|
|
8
20
|
codeceptjs.within = null;
|
|
9
21
|
|
|
10
22
|
// save
|
|
@@ -17,24 +29,50 @@ if (!window.codeceptjs) {
|
|
|
17
29
|
return els.map(el => storeElement(el));
|
|
18
30
|
};
|
|
19
31
|
|
|
20
|
-
|
|
32
|
+
/**
|
|
33
|
+
* finders
|
|
34
|
+
* @param {number} id
|
|
35
|
+
* @return {Node}
|
|
36
|
+
*/
|
|
21
37
|
codeceptjs.fetchElement = function (id) {
|
|
22
38
|
if (!this.elements[id]) throw new Error(`Element (${id}) is not accessible`);
|
|
23
39
|
return this.elements[id];
|
|
24
40
|
};
|
|
25
41
|
|
|
42
|
+
/**
|
|
43
|
+
* @param {string} by
|
|
44
|
+
* @param {CodeceptJS.ILocator} locator
|
|
45
|
+
* @param {*} [contextEl]
|
|
46
|
+
* @return {number[]}
|
|
47
|
+
*/
|
|
26
48
|
codeceptjs.findAndStoreElements = function (by, locator, contextEl) {
|
|
27
49
|
return storeElements(this.findElements(by, locator, contextEl));
|
|
28
50
|
};
|
|
29
51
|
|
|
52
|
+
/**
|
|
53
|
+
* @param {string} by
|
|
54
|
+
* @param {CodeceptJS.ILocator} locator
|
|
55
|
+
* @param {*} [contextEl]
|
|
56
|
+
* @return {number | undefined}
|
|
57
|
+
*/
|
|
30
58
|
codeceptjs.findAndStoreElement = function (by, locator, contextEl) {
|
|
31
59
|
return storeElement(this.findElement(by, locator, contextEl));
|
|
32
60
|
};
|
|
33
61
|
|
|
62
|
+
/**
|
|
63
|
+
* @param {string} by
|
|
64
|
+
* @param {CodeceptJS.ILocator} locator
|
|
65
|
+
*/
|
|
34
66
|
codeceptjs.setWithin = function (by, locator) {
|
|
35
67
|
this.within = this.findElement(by, locator);
|
|
36
68
|
};
|
|
37
69
|
|
|
70
|
+
/**
|
|
71
|
+
* @param {string} by
|
|
72
|
+
* @param {CodeceptJS.ILocator} locator
|
|
73
|
+
* @param {*} [contextEl]
|
|
74
|
+
* @return {Node[]}
|
|
75
|
+
*/
|
|
38
76
|
codeceptjs.findElements = function (by, locator, contextEl) {
|
|
39
77
|
let context;
|
|
40
78
|
if (typeof contextEl !== 'number') {
|
|
@@ -78,11 +116,21 @@ if (!window.codeceptjs) {
|
|
|
78
116
|
return [];
|
|
79
117
|
};
|
|
80
118
|
|
|
119
|
+
/**
|
|
120
|
+
* @param {string} by
|
|
121
|
+
* @param {CodeceptJS.ILocator} locator
|
|
122
|
+
* @param {*} [context]
|
|
123
|
+
* @return {?Node}
|
|
124
|
+
*/
|
|
81
125
|
codeceptjs.findElement = function (by, locator, context) {
|
|
82
126
|
return this.findElements(by, locator, context)[0] || null;
|
|
83
127
|
};
|
|
84
128
|
|
|
85
129
|
// actions
|
|
130
|
+
/**
|
|
131
|
+
* @param {number} el
|
|
132
|
+
* @return {boolean}
|
|
133
|
+
*/
|
|
86
134
|
codeceptjs.clickEl = function (el) {
|
|
87
135
|
if (document.activeElement instanceof HTMLElement) {
|
|
88
136
|
document.activeElement.blur();
|
|
@@ -92,6 +140,7 @@ if (!window.codeceptjs) {
|
|
|
92
140
|
return this.fetchElement(el).dispatchEvent(event);
|
|
93
141
|
};
|
|
94
142
|
|
|
143
|
+
/** @param {number} el */
|
|
95
144
|
codeceptjs.doubleClickEl = function (el) {
|
|
96
145
|
if (document.activeElement instanceof HTMLElement) {
|
|
97
146
|
document.activeElement.blur();
|
|
@@ -101,6 +150,11 @@ if (!window.codeceptjs) {
|
|
|
101
150
|
this.fetchElement(el).dispatchEvent(event);
|
|
102
151
|
};
|
|
103
152
|
|
|
153
|
+
/**
|
|
154
|
+
* @param {number} el
|
|
155
|
+
* @param {number | undefined} x
|
|
156
|
+
* @param {number | undefined} y
|
|
157
|
+
*/
|
|
104
158
|
codeceptjs.hoverEl = function (el, x, y) {
|
|
105
159
|
if (document.activeElement instanceof HTMLElement) {
|
|
106
160
|
document.activeElement.blur();
|
|
@@ -118,7 +172,7 @@ if (!window.codeceptjs) {
|
|
|
118
172
|
this.fetchElement(el).dispatchEvent(event);
|
|
119
173
|
};
|
|
120
174
|
|
|
121
|
-
|
|
175
|
+
/** @param {number} el */
|
|
122
176
|
codeceptjs.rightClickEl = function (el) {
|
|
123
177
|
const event = new MouseEvent('contextmenu', {
|
|
124
178
|
bubbles: true,
|
|
@@ -130,6 +184,10 @@ if (!window.codeceptjs) {
|
|
|
130
184
|
this.fetchElement(el).dispatchEvent(event);
|
|
131
185
|
};
|
|
132
186
|
|
|
187
|
+
/**
|
|
188
|
+
* @param {number} el
|
|
189
|
+
* @return {boolean | undefined}
|
|
190
|
+
*/
|
|
133
191
|
codeceptjs.checkEl = function (el) {
|
|
134
192
|
const element = this.fetchElement(el);
|
|
135
193
|
const event = document.createEvent('HTMLEvents');
|
|
@@ -139,6 +197,10 @@ if (!window.codeceptjs) {
|
|
|
139
197
|
return element.dispatchEvent(event);
|
|
140
198
|
};
|
|
141
199
|
|
|
200
|
+
/**
|
|
201
|
+
* @param {number} el
|
|
202
|
+
* @return {boolean}
|
|
203
|
+
*/
|
|
142
204
|
codeceptjs.unCheckEl = function (el) {
|
|
143
205
|
const element = this.fetchElement(el);
|
|
144
206
|
const event = document.createEvent('HTMLEvents');
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function isElementClickable(elem) {
|
|
2
|
+
if (!elem.getBoundingClientRect || !elem.scrollIntoView || !document.elementFromPoint) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const isElementInViewport = (elem) => {
|
|
7
|
+
const rect = elem.getBoundingClientRect();
|
|
8
|
+
const verticleInView = (rect.top <= window.innerHeight) && ((rect.top + rect.height) > 0);
|
|
9
|
+
const horizontalInView = (rect.left <= window.innerWidth) && ((rect.left + rect.width) > 0);
|
|
10
|
+
return horizontalInView && verticleInView;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const getOverlappingElement = (elem) => {
|
|
14
|
+
const rect = elem.getBoundingClientRect();
|
|
15
|
+
const x = rect.left + (elem.clientWidth / 2);
|
|
16
|
+
const y = rect.top + (elem.clientHeight / 2);
|
|
17
|
+
return document.elementFromPoint(x, y);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const isClickable = elem => elem.disabled !== true && isElementInViewport(elem) && getOverlappingElement(elem) === elem;
|
|
21
|
+
return isClickable(elem);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = isElementClickable;
|
package/lib/helper.js
CHANGED
|
@@ -21,6 +21,8 @@ class Helper {
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Abstract method to provide required config options
|
|
24
|
+
* @return {*}
|
|
25
|
+
* @protected
|
|
24
26
|
*/
|
|
25
27
|
static _config() {
|
|
26
28
|
|
|
@@ -29,6 +31,8 @@ class Helper {
|
|
|
29
31
|
/**
|
|
30
32
|
* Abstract method to validate config
|
|
31
33
|
* @param {*} config
|
|
34
|
+
* @returns {*}
|
|
35
|
+
* @protected
|
|
32
36
|
*/
|
|
33
37
|
_validateConfig(config) {
|
|
34
38
|
return config;
|
|
@@ -36,6 +40,8 @@ class Helper {
|
|
|
36
40
|
|
|
37
41
|
/**
|
|
38
42
|
* Sets config for current test
|
|
43
|
+
* @param {*} opts
|
|
44
|
+
* @protected
|
|
39
45
|
*/
|
|
40
46
|
_setConfig(opts) {
|
|
41
47
|
this.options = this._validateConfig(opts);
|
|
@@ -43,6 +49,7 @@ class Helper {
|
|
|
43
49
|
|
|
44
50
|
/**
|
|
45
51
|
* Hook executed before all tests
|
|
52
|
+
* @protected
|
|
46
53
|
*/
|
|
47
54
|
_init() {
|
|
48
55
|
|
|
@@ -50,6 +57,7 @@ class Helper {
|
|
|
50
57
|
|
|
51
58
|
/**
|
|
52
59
|
* Hook executed before each test.
|
|
60
|
+
* @protected
|
|
53
61
|
*/
|
|
54
62
|
_before() {
|
|
55
63
|
|
|
@@ -57,6 +65,7 @@ class Helper {
|
|
|
57
65
|
|
|
58
66
|
/**
|
|
59
67
|
* Hook executed after each test
|
|
68
|
+
* @protected
|
|
60
69
|
*/
|
|
61
70
|
_after() {
|
|
62
71
|
|
|
@@ -66,7 +75,8 @@ class Helper {
|
|
|
66
75
|
* Hook provides a test details
|
|
67
76
|
* Executed in the very beginning of a test
|
|
68
77
|
*
|
|
69
|
-
* @param {
|
|
78
|
+
* @param {Mocha.Test} test
|
|
79
|
+
* @protected
|
|
70
80
|
*/
|
|
71
81
|
_test(test) {
|
|
72
82
|
|
|
@@ -75,7 +85,8 @@ class Helper {
|
|
|
75
85
|
/**
|
|
76
86
|
* Hook executed after each passed test
|
|
77
87
|
*
|
|
78
|
-
* @param {
|
|
88
|
+
* @param {Mocha.Test} test
|
|
89
|
+
* @protected
|
|
79
90
|
*/
|
|
80
91
|
_passed(test) {
|
|
81
92
|
|
|
@@ -84,7 +95,8 @@ class Helper {
|
|
|
84
95
|
/**
|
|
85
96
|
* Hook executed after each failed test
|
|
86
97
|
*
|
|
87
|
-
* @param {
|
|
98
|
+
* @param {Mocha.Test} test
|
|
99
|
+
* @protected
|
|
88
100
|
*/
|
|
89
101
|
_failed(test) {
|
|
90
102
|
|
|
@@ -93,8 +105,8 @@ class Helper {
|
|
|
93
105
|
/**
|
|
94
106
|
* Hook executed before each step
|
|
95
107
|
*
|
|
96
|
-
* @param {
|
|
97
|
-
* @
|
|
108
|
+
* @param {CodeceptJS.Step} step
|
|
109
|
+
* @protected
|
|
98
110
|
*/
|
|
99
111
|
_beforeStep(step) {
|
|
100
112
|
|
|
@@ -103,8 +115,8 @@ class Helper {
|
|
|
103
115
|
/**
|
|
104
116
|
* Hook executed after each step
|
|
105
117
|
*
|
|
106
|
-
* @param {
|
|
107
|
-
* @
|
|
118
|
+
* @param {CodeceptJS.Step} step
|
|
119
|
+
* @protected
|
|
108
120
|
*/
|
|
109
121
|
_afterStep(step) {
|
|
110
122
|
|
|
@@ -113,7 +125,8 @@ class Helper {
|
|
|
113
125
|
/**
|
|
114
126
|
* Hook executed before each suite
|
|
115
127
|
*
|
|
116
|
-
* @param {
|
|
128
|
+
* @param {Mocha.Suite} suite
|
|
129
|
+
* @protected
|
|
117
130
|
*/
|
|
118
131
|
_beforeSuite(suite) {
|
|
119
132
|
|
|
@@ -122,7 +135,8 @@ class Helper {
|
|
|
122
135
|
/**
|
|
123
136
|
* Hook executed after each suite
|
|
124
137
|
*
|
|
125
|
-
* @param {
|
|
138
|
+
* @param {Mocha.Suite} suite
|
|
139
|
+
* @protected
|
|
126
140
|
*/
|
|
127
141
|
_afterSuite(suite) {
|
|
128
142
|
|
|
@@ -131,7 +145,8 @@ class Helper {
|
|
|
131
145
|
/**
|
|
132
146
|
* Hook executed after all tests are executed
|
|
133
147
|
*
|
|
134
|
-
* @param {
|
|
148
|
+
* @param {Mocha.Suite} suite
|
|
149
|
+
* @protected
|
|
135
150
|
*/
|
|
136
151
|
_finishTest(suite) {
|
|
137
152
|
|
|
@@ -139,6 +154,9 @@ class Helper {
|
|
|
139
154
|
|
|
140
155
|
/**
|
|
141
156
|
* Access another configured helper: `this.helpers['AnotherHelper']`
|
|
157
|
+
*
|
|
158
|
+
* @readonly
|
|
159
|
+
* @type {*}
|
|
142
160
|
*/
|
|
143
161
|
get helpers() {
|
|
144
162
|
return container.helpers();
|
|
@@ -146,11 +164,17 @@ class Helper {
|
|
|
146
164
|
|
|
147
165
|
/**
|
|
148
166
|
* Print debug message to console (outputs only in debug mode)
|
|
167
|
+
*
|
|
168
|
+
* @param {string} msg
|
|
149
169
|
*/
|
|
150
170
|
debug(msg) {
|
|
151
171
|
output.debug(msg);
|
|
152
172
|
}
|
|
153
173
|
|
|
174
|
+
/**
|
|
175
|
+
* @param {string} section
|
|
176
|
+
* @param {string} msg
|
|
177
|
+
*/
|
|
154
178
|
debugSection(section, msg) {
|
|
155
179
|
output.debug(`[${section}] ${msg}`);
|
|
156
180
|
}
|
package/lib/history.js
CHANGED
package/lib/hooks.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -2,19 +2,38 @@
|
|
|
2
2
|
* Index file for loading CodeceptJS programmatically.
|
|
3
3
|
*
|
|
4
4
|
* Includes Public API objects
|
|
5
|
+
* @alias index
|
|
6
|
+
* @namespace
|
|
5
7
|
*/
|
|
6
8
|
module.exports = {
|
|
9
|
+
/** @type {typeof CodeceptJS.Codecept} */
|
|
7
10
|
codecept: require('./codecept'),
|
|
11
|
+
/** @type {typeof CodeceptJS.Codecept} */
|
|
12
|
+
Codecept: require('./codecept'),
|
|
13
|
+
/** @type {typeof CodeceptJS.output} */
|
|
8
14
|
output: require('./output'),
|
|
15
|
+
/** @type {typeof CodeceptJS.Container} */
|
|
9
16
|
container: require('./container'),
|
|
17
|
+
/** @type {typeof CodeceptJS.event} */
|
|
10
18
|
event: require('./event'),
|
|
19
|
+
/** @type {CodeceptJS.recorder} */
|
|
11
20
|
recorder: require('./recorder'),
|
|
21
|
+
/** @type {typeof CodeceptJS.Config} */
|
|
12
22
|
config: require('./config'),
|
|
23
|
+
/** @type {CodeceptJS.actor} */
|
|
13
24
|
actor: require('./actor'),
|
|
25
|
+
/** @type {typeof CodeceptJS.Helper} */
|
|
14
26
|
helper: require('./helper'),
|
|
27
|
+
/** @type {typeof CodeceptJS.Helper} */
|
|
28
|
+
Helper: require('./helper'),
|
|
29
|
+
/** @type {typeof CodeceptJS.pause} */
|
|
15
30
|
pause: require('./pause'),
|
|
31
|
+
/** @type {typeof CodeceptJS.within} */
|
|
16
32
|
within: require('./within'),
|
|
33
|
+
/** @type {typeof CodeceptJS.DataTable} */
|
|
17
34
|
dataTable: require('./data/table'),
|
|
35
|
+
/** @type {typeof CodeceptJS.store} */
|
|
18
36
|
store: require('./store'),
|
|
37
|
+
/** @type {typeof CodeceptJS.Locator} */
|
|
19
38
|
locator: require('./locator'),
|
|
20
39
|
};
|
package/lib/interfaces/bdd.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @class */
|
|
1
2
|
class FeatureConfig {
|
|
2
3
|
constructor(suite) {
|
|
3
4
|
this.suite = suite;
|
|
@@ -6,7 +7,8 @@ class FeatureConfig {
|
|
|
6
7
|
/**
|
|
7
8
|
* Retry this suite for x times
|
|
8
9
|
*
|
|
9
|
-
* @param {
|
|
10
|
+
* @param {number} retries
|
|
11
|
+
* @returns {this}
|
|
10
12
|
*/
|
|
11
13
|
retry(retries) {
|
|
12
14
|
this.suite.retries(retries);
|
|
@@ -15,7 +17,8 @@ class FeatureConfig {
|
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Set timeout for this suite
|
|
18
|
-
* @param {
|
|
20
|
+
* @param {number} timeout
|
|
21
|
+
* @returns {this}
|
|
19
22
|
*/
|
|
20
23
|
timeout(timeout) {
|
|
21
24
|
this.suite.timeout(timeout);
|
|
@@ -25,6 +28,9 @@ class FeatureConfig {
|
|
|
25
28
|
/**
|
|
26
29
|
* Configures a helper.
|
|
27
30
|
* Helper name can be omitted and values will be applied to first helper.
|
|
31
|
+
* @param {string | Object<string, *>} helper
|
|
32
|
+
* @param {Object<string, *>} [obj]
|
|
33
|
+
* @returns {this}
|
|
28
34
|
*/
|
|
29
35
|
config(helper, obj) {
|
|
30
36
|
if (!obj) {
|
|
@@ -44,7 +50,8 @@ class FeatureConfig {
|
|
|
44
50
|
|
|
45
51
|
/**
|
|
46
52
|
* Append a tag name to scenario title
|
|
47
|
-
* @param {
|
|
53
|
+
* @param {string} tagName
|
|
54
|
+
* @returns {this}
|
|
48
55
|
*/
|
|
49
56
|
tag(tagName) {
|
|
50
57
|
if (tagName[0] !== '@') {
|
|
@@ -6,6 +6,7 @@ const { isAsyncFunction } = require('../utils');
|
|
|
6
6
|
const event = require('../event');
|
|
7
7
|
const scenario = require('../scenario');
|
|
8
8
|
const Step = require('../step');
|
|
9
|
+
const DataTableArgument = require('../data/dataTableArgument');
|
|
9
10
|
|
|
10
11
|
const parser = new Parser();
|
|
11
12
|
parser.stopAtFirstError = false;
|
|
@@ -36,6 +37,9 @@ module.exports = (text) => {
|
|
|
36
37
|
};
|
|
37
38
|
const fn = matchStep(step.text);
|
|
38
39
|
if (step.argument) {
|
|
40
|
+
step.argument.parse = () => {
|
|
41
|
+
return new DataTableArgument(step.argument);
|
|
42
|
+
};
|
|
39
43
|
fn.params.push(step.argument);
|
|
40
44
|
if (step.argument.type === 'DataTable') metaStep.comment = `\n${transformTable(step.argument)}`;
|
|
41
45
|
if (step.argument.content) metaStep.comment = `\n${step.argument.content}`;
|
|
@@ -65,7 +69,7 @@ module.exports = (text) => {
|
|
|
65
69
|
const value = example.cells[index].value;
|
|
66
70
|
current[placeholder] = value;
|
|
67
71
|
exampleSteps = exampleSteps.map((step) => {
|
|
68
|
-
step =
|
|
72
|
+
step = { ...step };
|
|
69
73
|
step.text = step.text.replace(`<${placeholder}>`, value);
|
|
70
74
|
return step;
|
|
71
75
|
});
|
|
@@ -102,7 +106,7 @@ function addExampleInTable(exampleSteps, placeholders) {
|
|
|
102
106
|
const steps = JSON.parse(JSON.stringify(exampleSteps));
|
|
103
107
|
for (const placeholder in placeholders) {
|
|
104
108
|
steps.map((step) => {
|
|
105
|
-
step =
|
|
109
|
+
step = { ...step };
|
|
106
110
|
if (step.argument && step.argument.type === 'DataTable') {
|
|
107
111
|
for (const id in step.argument.rows) {
|
|
108
112
|
const cells = step.argument.rows[id].cells;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @class */
|
|
1
2
|
class ScenarioConfig {
|
|
2
3
|
constructor(test) {
|
|
3
4
|
this.test = test;
|
|
@@ -8,6 +9,7 @@ class ScenarioConfig {
|
|
|
8
9
|
* Can pass an Error object or regex matching expected message.
|
|
9
10
|
*
|
|
10
11
|
* @param {*} err
|
|
12
|
+
* @returns {this}
|
|
11
13
|
*/
|
|
12
14
|
throws(err) {
|
|
13
15
|
this.test.throws = err;
|
|
@@ -19,7 +21,7 @@ class ScenarioConfig {
|
|
|
19
21
|
* If test passes - throws an error.
|
|
20
22
|
* Can pass an Error object or regex matching expected message.
|
|
21
23
|
*
|
|
22
|
-
* @
|
|
24
|
+
* @returns {this}
|
|
23
25
|
*/
|
|
24
26
|
fails() {
|
|
25
27
|
this.test.throws = new Error();
|
|
@@ -29,7 +31,8 @@ class ScenarioConfig {
|
|
|
29
31
|
/**
|
|
30
32
|
* Retry this test for x times
|
|
31
33
|
*
|
|
32
|
-
* @param {
|
|
34
|
+
* @param {number} retries
|
|
35
|
+
* @returns {this}
|
|
33
36
|
*/
|
|
34
37
|
retry(retries) {
|
|
35
38
|
this.test.retries(retries);
|
|
@@ -38,7 +41,8 @@ class ScenarioConfig {
|
|
|
38
41
|
|
|
39
42
|
/**
|
|
40
43
|
* Set timeout for this test
|
|
41
|
-
* @param {
|
|
44
|
+
* @param {number} timeout
|
|
45
|
+
* @returns {this}
|
|
42
46
|
*/
|
|
43
47
|
timeout(timeout) {
|
|
44
48
|
this.test.timeout(timeout);
|
|
@@ -47,7 +51,8 @@ class ScenarioConfig {
|
|
|
47
51
|
|
|
48
52
|
/**
|
|
49
53
|
* Pass in additional objects to inject into test
|
|
50
|
-
* @param {
|
|
54
|
+
* @param {Object<string, any>} obj
|
|
55
|
+
* @returns {this}
|
|
51
56
|
*/
|
|
52
57
|
inject(obj) {
|
|
53
58
|
this.test.inject = obj;
|
|
@@ -57,6 +62,9 @@ class ScenarioConfig {
|
|
|
57
62
|
/**
|
|
58
63
|
* Configures a helper.
|
|
59
64
|
* Helper name can be omitted and values will be applied to first helper.
|
|
65
|
+
* @param {string | Object<string, any>} helper
|
|
66
|
+
* @param {Object<string, any>} [obj]
|
|
67
|
+
* @returns {this}
|
|
60
68
|
*/
|
|
61
69
|
async config(helper, obj) {
|
|
62
70
|
if (!obj) {
|
|
@@ -75,7 +83,8 @@ class ScenarioConfig {
|
|
|
75
83
|
|
|
76
84
|
/**
|
|
77
85
|
* Append a tag name to scenario title
|
|
78
|
-
* @param {
|
|
86
|
+
* @param {string} tagName
|
|
87
|
+
* @returns {this}
|
|
79
88
|
*/
|
|
80
89
|
tag(tagName) {
|
|
81
90
|
if (tagName[0] !== '@') tagName = `@${tagName}`;
|
|
@@ -86,12 +95,14 @@ class ScenarioConfig {
|
|
|
86
95
|
|
|
87
96
|
/**
|
|
88
97
|
* Dynamically injects dependencies, see https://codecept.io/pageobjects/#dynamic-injection
|
|
89
|
-
* @param {
|
|
98
|
+
* @param {Object<string, *>} dependencies
|
|
99
|
+
* @returns {this}
|
|
90
100
|
*/
|
|
91
101
|
injectDependencies(dependencies) {
|
|
92
102
|
Object.keys(dependencies).forEach((key) => {
|
|
93
103
|
this.test.inject[key] = dependencies[key];
|
|
94
104
|
});
|
|
105
|
+
return this;
|
|
95
106
|
}
|
|
96
107
|
}
|
|
97
108
|
|
package/lib/listener/config.js
CHANGED
|
@@ -15,7 +15,7 @@ module.exports = function () {
|
|
|
15
15
|
function enableDynamicConfigFor(type) {
|
|
16
16
|
event.dispatcher.on(event[type].before, (context = {}) => {
|
|
17
17
|
function updateHelperConfig(helper, config) {
|
|
18
|
-
const oldConfig =
|
|
18
|
+
const oldConfig = { ...helper.options };
|
|
19
19
|
try {
|
|
20
20
|
helper._setConfig(deepMerge(deepClone(oldConfig), config));
|
|
21
21
|
debug(`[${ucfirst(type)} Config] ${helper.constructor.name} ${JSON.stringify(config)}`);
|
package/lib/listener/exit.js
CHANGED
package/lib/listener/steps.js
CHANGED
package/lib/listener/trace.js
CHANGED