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,213 +0,0 @@
|
|
|
1
|
-
if (!window.codeceptjs) {
|
|
2
|
-
/**
|
|
3
|
-
* @alias CodeceptJS.browserCodecept
|
|
4
|
-
* @namespace
|
|
5
|
-
*/
|
|
6
|
-
const codeceptjs = {};
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* all found elements are stored here for reuse
|
|
10
|
-
* @inner
|
|
11
|
-
* @type {Node[]}
|
|
12
|
-
*/
|
|
13
|
-
codeceptjs.elements = [];
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* global context changer
|
|
17
|
-
* @inner
|
|
18
|
-
* @type {?Node}
|
|
19
|
-
*/
|
|
20
|
-
codeceptjs.within = null;
|
|
21
|
-
|
|
22
|
-
// save
|
|
23
|
-
const storeElement = function (el) {
|
|
24
|
-
if (!el) return;
|
|
25
|
-
return codeceptjs.elements.push(el) - 1; // return index
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const storeElements = function (els) {
|
|
29
|
-
return els.map(el => storeElement(el));
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* finders
|
|
34
|
-
* @param {number} id
|
|
35
|
-
* @return {Node}
|
|
36
|
-
*/
|
|
37
|
-
codeceptjs.fetchElement = function (id) {
|
|
38
|
-
if (!this.elements[id]) throw new Error(`Element (${id}) is not accessible`);
|
|
39
|
-
return this.elements[id];
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @param {string} by
|
|
44
|
-
* @param {CodeceptJS.ILocator} locator
|
|
45
|
-
* @param {*} [contextEl]
|
|
46
|
-
* @return {number[]}
|
|
47
|
-
*/
|
|
48
|
-
codeceptjs.findAndStoreElements = function (by, locator, contextEl) {
|
|
49
|
-
return storeElements(this.findElements(by, locator, contextEl));
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @param {string} by
|
|
54
|
-
* @param {CodeceptJS.ILocator} locator
|
|
55
|
-
* @param {*} [contextEl]
|
|
56
|
-
* @return {number | undefined}
|
|
57
|
-
*/
|
|
58
|
-
codeceptjs.findAndStoreElement = function (by, locator, contextEl) {
|
|
59
|
-
return storeElement(this.findElement(by, locator, contextEl));
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @param {string} by
|
|
64
|
-
* @param {CodeceptJS.ILocator} locator
|
|
65
|
-
*/
|
|
66
|
-
codeceptjs.setWithin = function (by, locator) {
|
|
67
|
-
this.within = this.findElement(by, locator);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @param {string} by
|
|
72
|
-
* @param {CodeceptJS.ILocator} locator
|
|
73
|
-
* @param {*} [contextEl]
|
|
74
|
-
* @return {Node[]}
|
|
75
|
-
*/
|
|
76
|
-
codeceptjs.findElements = function (by, locator, contextEl) {
|
|
77
|
-
let context;
|
|
78
|
-
if (typeof contextEl !== 'number') {
|
|
79
|
-
context = this.within || document;
|
|
80
|
-
} else {
|
|
81
|
-
context = this.fetchElement(contextEl);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (by === 'name') {
|
|
85
|
-
by = 'css';
|
|
86
|
-
locator = `*[name="${locator}"]`;
|
|
87
|
-
}
|
|
88
|
-
if (by === 'id') {
|
|
89
|
-
by = 'css';
|
|
90
|
-
locator = `#${locator}`;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (by === 'css') {
|
|
94
|
-
const found = context.querySelectorAll(locator);
|
|
95
|
-
const res = [];
|
|
96
|
-
for (let i = 0; i < found.length; i++) {
|
|
97
|
-
res.push(found[i]);
|
|
98
|
-
}
|
|
99
|
-
return res;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (by === 'xpath') {
|
|
103
|
-
const found = document.evaluate(locator, context, null, 5, null);
|
|
104
|
-
const res = [];
|
|
105
|
-
let current = null;
|
|
106
|
-
while (current = found.iterateNext()) {
|
|
107
|
-
res.push(current);
|
|
108
|
-
}
|
|
109
|
-
return res;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (by === 'frame') {
|
|
113
|
-
if (!Array.isArray(locator)) locator = [locator];
|
|
114
|
-
return [locator.reduce((parent, child) => parent.querySelector(child).contentDocument, window.document).querySelector('body')];
|
|
115
|
-
}
|
|
116
|
-
return [];
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* @param {string} by
|
|
121
|
-
* @param {CodeceptJS.ILocator} locator
|
|
122
|
-
* @param {*} [context]
|
|
123
|
-
* @return {?Node}
|
|
124
|
-
*/
|
|
125
|
-
codeceptjs.findElement = function (by, locator, context) {
|
|
126
|
-
return this.findElements(by, locator, context)[0] || null;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// actions
|
|
130
|
-
/**
|
|
131
|
-
* @param {number} el
|
|
132
|
-
* @return {boolean}
|
|
133
|
-
*/
|
|
134
|
-
codeceptjs.clickEl = function (el) {
|
|
135
|
-
if (document.activeElement instanceof HTMLElement) {
|
|
136
|
-
document.activeElement.blur();
|
|
137
|
-
}
|
|
138
|
-
const event = document.createEvent('MouseEvent');
|
|
139
|
-
event.initEvent('click', true, true);
|
|
140
|
-
return this.fetchElement(el).dispatchEvent(event);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
/** @param {number} el */
|
|
144
|
-
codeceptjs.doubleClickEl = function (el) {
|
|
145
|
-
if (document.activeElement instanceof HTMLElement) {
|
|
146
|
-
document.activeElement.blur();
|
|
147
|
-
}
|
|
148
|
-
const event = document.createEvent('MouseEvent');
|
|
149
|
-
event.initEvent('dblclick', true, true);
|
|
150
|
-
this.fetchElement(el).dispatchEvent(event);
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* @param {number} el
|
|
155
|
-
* @param {number | undefined} x
|
|
156
|
-
* @param {number | undefined} y
|
|
157
|
-
*/
|
|
158
|
-
codeceptjs.hoverEl = function (el, x, y) {
|
|
159
|
-
if (document.activeElement instanceof HTMLElement) {
|
|
160
|
-
document.activeElement.blur();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const event = new MouseEvent('mouseover', {
|
|
164
|
-
bubbles: true,
|
|
165
|
-
cancelable: true,
|
|
166
|
-
screenX: x,
|
|
167
|
-
screenY: y,
|
|
168
|
-
clientX: x,
|
|
169
|
-
clientY: y,
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
this.fetchElement(el).dispatchEvent(event);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
/** @param {number} el */
|
|
176
|
-
codeceptjs.rightClickEl = function (el) {
|
|
177
|
-
const event = new MouseEvent('contextmenu', {
|
|
178
|
-
bubbles: true,
|
|
179
|
-
cancelable: true,
|
|
180
|
-
view: window,
|
|
181
|
-
buttons: 2,
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
this.fetchElement(el).dispatchEvent(event);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* @param {number} el
|
|
189
|
-
* @return {boolean | undefined}
|
|
190
|
-
*/
|
|
191
|
-
codeceptjs.checkEl = function (el) {
|
|
192
|
-
const element = this.fetchElement(el);
|
|
193
|
-
const event = document.createEvent('HTMLEvents');
|
|
194
|
-
if (element.checked) return;
|
|
195
|
-
element.checked = true;
|
|
196
|
-
event.initEvent('change', true, true);
|
|
197
|
-
return element.dispatchEvent(event);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* @param {number} el
|
|
202
|
-
* @return {boolean}
|
|
203
|
-
*/
|
|
204
|
-
codeceptjs.unCheckEl = function (el) {
|
|
205
|
-
const element = this.fetchElement(el);
|
|
206
|
-
const event = document.createEvent('HTMLEvents');
|
|
207
|
-
element.checked = false;
|
|
208
|
-
event.initEvent('change', true, true);
|
|
209
|
-
return element.dispatchEvent(event);
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
window.codeceptjs = codeceptjs;
|
|
213
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
async function findReact(matcher, locator) {
|
|
2
|
-
let _locator = `_react=${locator.react}`;
|
|
3
|
-
let props = '';
|
|
4
|
-
|
|
5
|
-
if (locator.props) {
|
|
6
|
-
props += propBuilder(locator.props);
|
|
7
|
-
_locator += props;
|
|
8
|
-
}
|
|
9
|
-
return matcher.locator(_locator).all();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async function findVue(matcher, locator) {
|
|
13
|
-
let _locator = `_vue=${locator.vue}`;
|
|
14
|
-
let props = '';
|
|
15
|
-
|
|
16
|
-
if (locator.props) {
|
|
17
|
-
props += propBuilder(locator.props);
|
|
18
|
-
_locator += props;
|
|
19
|
-
}
|
|
20
|
-
return matcher.locator(_locator).all();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function findByPlaywrightLocator(matcher, locator) {
|
|
24
|
-
if (locator && locator.toString().includes(process.env.testIdAttribute)) return matcher.getByTestId(locator.pw.value.split('=')[1]);
|
|
25
|
-
return matcher.locator(locator.pw).all();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function propBuilder(props) {
|
|
29
|
-
let _props = '';
|
|
30
|
-
|
|
31
|
-
for (const [key, value] of Object.entries(props)) {
|
|
32
|
-
if (typeof value === 'object') {
|
|
33
|
-
for (const [k, v] of Object.entries(value)) {
|
|
34
|
-
_props += `[${key}.${k} = "${v}"]`;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
_props += `[${key} = "${value}"]`;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return _props;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
module.exports = { findReact, findVue, findByPlaywrightLocator };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const testControllerHolder = {
|
|
2
|
-
|
|
3
|
-
testController: undefined,
|
|
4
|
-
captureResolver: undefined,
|
|
5
|
-
getResolver: undefined,
|
|
6
|
-
|
|
7
|
-
capture(t) {
|
|
8
|
-
testControllerHolder.testController = t;
|
|
9
|
-
|
|
10
|
-
if (testControllerHolder.getResolver) {
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
testControllerHolder.getResolver(t);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return new Promise((resolve) => {
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
testControllerHolder.captureResolver = resolve;
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
free() {
|
|
22
|
-
testControllerHolder.testController = undefined;
|
|
23
|
-
|
|
24
|
-
if (testControllerHolder.captureResolver) {
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
testControllerHolder.captureResolver();
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
get() {
|
|
31
|
-
return new Promise((resolve) => {
|
|
32
|
-
if (testControllerHolder.testController) {
|
|
33
|
-
resolve(testControllerHolder.testController);
|
|
34
|
-
} else {
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
testControllerHolder.getResolver = resolve;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
module.exports = testControllerHolder;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const { ClientFunction } = require('testcafe')
|
|
2
|
-
|
|
3
|
-
const assert = require('assert')
|
|
4
|
-
const fs = require('fs')
|
|
5
|
-
const path = require('path')
|
|
6
|
-
const { getParamNames } = require('../../utils')
|
|
7
|
-
|
|
8
|
-
const createTestFile = () => {
|
|
9
|
-
assert(global.output_dir, 'global.output_dir must be set')
|
|
10
|
-
|
|
11
|
-
const testFile = path.join(global.output_dir, `${Date.now()}_test.js`)
|
|
12
|
-
const testControllerHolderDir = __dirname.replace(/\\/g, '/')
|
|
13
|
-
|
|
14
|
-
fs.writeFileSync(
|
|
15
|
-
testFile,
|
|
16
|
-
`import testControllerHolder from "${testControllerHolderDir}/testControllerHolder.js";\n\n
|
|
17
|
-
fixture("fixture")\n
|
|
18
|
-
test\n
|
|
19
|
-
("test", testControllerHolder.capture)`,
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
return testFile
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// TODO Better error mapping (actual, expected)
|
|
26
|
-
const mapError = testcafeError => {
|
|
27
|
-
// console.log('TODO map error better', JSON.stringify(testcafeError, null, 2));
|
|
28
|
-
if (testcafeError.errMsg) {
|
|
29
|
-
throw new Error(testcafeError.errMsg)
|
|
30
|
-
}
|
|
31
|
-
const errorInfo = `${testcafeError.callsite ? JSON.stringify(testcafeError.callsite) : ''} ${testcafeError.apiFnChain || JSON.stringify(testcafeError)}`
|
|
32
|
-
throw new Error(`TestCafe Error: ${errorInfo}`)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function createClientFunction(func, args) {
|
|
36
|
-
if (!args || !args.length) {
|
|
37
|
-
return ClientFunction(func)
|
|
38
|
-
}
|
|
39
|
-
const paramNames = getParamNames(func)
|
|
40
|
-
const dependencies = {}
|
|
41
|
-
paramNames.forEach((param, i) => (dependencies[param] = args[i]))
|
|
42
|
-
|
|
43
|
-
return ClientFunction(getFuncBody(func), { dependencies })
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getFuncBody(func) {
|
|
47
|
-
let fnStr = func.toString()
|
|
48
|
-
const arrowIndex = fnStr.indexOf('=>')
|
|
49
|
-
if (arrowIndex >= 0) {
|
|
50
|
-
fnStr = fnStr.slice(arrowIndex + 2)
|
|
51
|
-
|
|
52
|
-
return eval(`() => ${fnStr}`)
|
|
53
|
-
}
|
|
54
|
-
// TODO: support general functions
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
module.exports = {
|
|
58
|
-
createTestFile,
|
|
59
|
-
mapError,
|
|
60
|
-
createClientFunction,
|
|
61
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
const event = require('../event')
|
|
2
|
-
const { enhanceMochaTest } = require('../mocha/test')
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Enhance retried tests by copying CodeceptJS-specific properties from the original test
|
|
6
|
-
* This fixes the issue where Mocha's shallow clone during retries loses CodeceptJS properties
|
|
7
|
-
*/
|
|
8
|
-
module.exports = function () {
|
|
9
|
-
event.dispatcher.on(event.test.before, test => {
|
|
10
|
-
// Check if this test is a retry (has a reference to the original test)
|
|
11
|
-
const originalTest = test.retriedTest && test.retriedTest()
|
|
12
|
-
|
|
13
|
-
if (originalTest) {
|
|
14
|
-
// This is a retried test - copy CodeceptJS-specific properties from the original
|
|
15
|
-
copyCodeceptJSProperties(originalTest, test)
|
|
16
|
-
|
|
17
|
-
// Ensure the test is enhanced with CodeceptJS functionality
|
|
18
|
-
enhanceMochaTest(test)
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Copy CodeceptJS-specific properties from the original test to the retried test
|
|
25
|
-
* @param {CodeceptJS.Test} originalTest - The original test object
|
|
26
|
-
* @param {CodeceptJS.Test} retriedTest - The retried test object
|
|
27
|
-
*/
|
|
28
|
-
function copyCodeceptJSProperties(originalTest, retriedTest) {
|
|
29
|
-
// Copy CodeceptJS-specific properties
|
|
30
|
-
if (originalTest.opts !== undefined) {
|
|
31
|
-
retriedTest.opts = originalTest.opts ? { ...originalTest.opts } : {}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (originalTest.tags !== undefined) {
|
|
35
|
-
retriedTest.tags = originalTest.tags ? [...originalTest.tags] : []
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (originalTest.notes !== undefined) {
|
|
39
|
-
retriedTest.notes = originalTest.notes ? [...originalTest.notes] : []
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (originalTest.meta !== undefined) {
|
|
43
|
-
retriedTest.meta = originalTest.meta ? { ...originalTest.meta } : {}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (originalTest.artifacts !== undefined) {
|
|
47
|
-
retriedTest.artifacts = originalTest.artifacts ? [...originalTest.artifacts] : []
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (originalTest.steps !== undefined) {
|
|
51
|
-
retriedTest.steps = originalTest.steps ? [...originalTest.steps] : []
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (originalTest.config !== undefined) {
|
|
55
|
-
retriedTest.config = originalTest.config ? { ...originalTest.config } : {}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (originalTest.inject !== undefined) {
|
|
59
|
-
retriedTest.inject = originalTest.inject ? { ...originalTest.inject } : {}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Copy methods that might be missing
|
|
63
|
-
if (originalTest.addNote && !retriedTest.addNote) {
|
|
64
|
-
retriedTest.addNote = function (type, note) {
|
|
65
|
-
this.notes = this.notes || []
|
|
66
|
-
this.notes.push({ type, text: note })
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (originalTest.applyOptions && !retriedTest.applyOptions) {
|
|
71
|
-
retriedTest.applyOptions = originalTest.applyOptions.bind(retriedTest)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (originalTest.simplify && !retriedTest.simplify) {
|
|
75
|
-
retriedTest.simplify = originalTest.simplify.bind(retriedTest)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Preserve the uid if it exists
|
|
79
|
-
if (originalTest.uid !== undefined) {
|
|
80
|
-
retriedTest.uid = originalTest.uid
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Mark as enhanced
|
|
84
|
-
retriedTest.codeceptjs = true
|
|
85
|
-
}
|
package/lib/plugin/allure.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module.exports = () => {
|
|
2
|
-
console.log('Allure plugin was moved to @codeceptjs/allure-legacy. Please install it and update your config')
|
|
3
|
-
console.log()
|
|
4
|
-
console.log('npm install @codeceptjs/allure-legacy --save-dev')
|
|
5
|
-
console.log()
|
|
6
|
-
console.log('Then update your config to use it:')
|
|
7
|
-
console.log()
|
|
8
|
-
console.log('plugins: {')
|
|
9
|
-
console.log(' allure: {')
|
|
10
|
-
console.log(' enabled: true,')
|
|
11
|
-
console.log(" require: '@codeceptjs/allure-legacy',")
|
|
12
|
-
console.log(' }')
|
|
13
|
-
console.log('}')
|
|
14
|
-
console.log()
|
|
15
|
-
}
|
package/lib/plugin/autoLogin.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
const event = require('../event')
|
|
2
|
-
const recorder = require('../recorder')
|
|
3
|
-
const { MetaStep } = require('../step')
|
|
4
|
-
|
|
5
|
-
let currentCommentStep
|
|
6
|
-
|
|
7
|
-
const defaultGlobalName = '__'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* This plugin is **deprecated**, use `Section` instead.
|
|
11
|
-
*
|
|
12
|
-
* Add descriptive nested steps for your tests:
|
|
13
|
-
*
|
|
14
|
-
* ```js
|
|
15
|
-
* Scenario('project update test', async (I) => {
|
|
16
|
-
* __`Given`;
|
|
17
|
-
* const projectId = await I.have('project');
|
|
18
|
-
*
|
|
19
|
-
* __`When`;
|
|
20
|
-
* projectPage.update(projectId, { title: 'new title' });
|
|
21
|
-
*
|
|
22
|
-
* __`Then`;
|
|
23
|
-
* projectPage.open(projectId);
|
|
24
|
-
* I.see('new title', 'h1');
|
|
25
|
-
* })
|
|
26
|
-
* ```
|
|
27
|
-
* Steps prefixed with `__` will be printed as nested steps in `--steps` output:
|
|
28
|
-
*
|
|
29
|
-
* ```
|
|
30
|
-
* Given
|
|
31
|
-
* I have "project"
|
|
32
|
-
* When
|
|
33
|
-
* projectPage update
|
|
34
|
-
* Then
|
|
35
|
-
* projectPage open
|
|
36
|
-
* I see "new title", "h1"
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* Also those steps will be exported to allure reports.
|
|
40
|
-
*
|
|
41
|
-
* This plugin can be used
|
|
42
|
-
*
|
|
43
|
-
* ### Config
|
|
44
|
-
*
|
|
45
|
-
* * `enabled` - (default: false) enable a plugin
|
|
46
|
-
* * `registerGlobal` - (default: false) register `__` template literal function globally. You can override function global name by providing a name as a value.
|
|
47
|
-
*
|
|
48
|
-
* ### Examples
|
|
49
|
-
*
|
|
50
|
-
* Registering `__` globally:
|
|
51
|
-
*
|
|
52
|
-
* ```js
|
|
53
|
-
* plugins: {
|
|
54
|
-
* commentStep: {
|
|
55
|
-
* enabled: true,
|
|
56
|
-
* registerGlobal: true
|
|
57
|
-
* }
|
|
58
|
-
* }
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* Registering `Step` globally:
|
|
62
|
-
* ```js
|
|
63
|
-
* plugins: {
|
|
64
|
-
* commentStep: {
|
|
65
|
-
* enabled: true,
|
|
66
|
-
* registerGlobal: 'Step'
|
|
67
|
-
* }
|
|
68
|
-
* }
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* Using only local function names:
|
|
72
|
-
* ```js
|
|
73
|
-
* plugins: {
|
|
74
|
-
* commentStep: {
|
|
75
|
-
* enabled: true
|
|
76
|
-
* }
|
|
77
|
-
* }
|
|
78
|
-
* ```
|
|
79
|
-
* Then inside a test import a comment function from a plugin.
|
|
80
|
-
* For instance, you can prepare Given/When/Then functions to use them inside tests:
|
|
81
|
-
*
|
|
82
|
-
* ```js
|
|
83
|
-
* // inside a test
|
|
84
|
-
* const step = codeceptjs.container.plugins('commentStep');
|
|
85
|
-
*
|
|
86
|
-
* const Given = () => step`Given`;
|
|
87
|
-
* const When = () => step`When`;
|
|
88
|
-
* const Then = () => step`Then`;
|
|
89
|
-
* ```
|
|
90
|
-
*
|
|
91
|
-
* Scenario('project update test', async (I) => {
|
|
92
|
-
* Given();
|
|
93
|
-
* const projectId = await I.have('project');
|
|
94
|
-
*
|
|
95
|
-
* When();
|
|
96
|
-
* projectPage.update(projectId, { title: 'new title' });
|
|
97
|
-
*
|
|
98
|
-
* Then();
|
|
99
|
-
* projectPage.open(projectId);
|
|
100
|
-
* I.see('new title', 'h1');
|
|
101
|
-
* });
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
module.exports = function (config) {
|
|
105
|
-
console.log('commentStep is deprecated, disable it and use Section instead')
|
|
106
|
-
console.log('const { Section: __ } = require("codeceptjs/steps")')
|
|
107
|
-
|
|
108
|
-
event.dispatcher.on(event.test.started, () => {
|
|
109
|
-
currentCommentStep = null
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
event.dispatcher.on(event.step.started, step => {
|
|
113
|
-
if (currentCommentStep) {
|
|
114
|
-
const metaStep = getRootMetaStep(step)
|
|
115
|
-
|
|
116
|
-
if (metaStep !== currentCommentStep) {
|
|
117
|
-
metaStep.metaStep = currentCommentStep
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
if (config.registerGlobal) {
|
|
123
|
-
if (config.registerGlobal === true) {
|
|
124
|
-
config.registerGlobal = defaultGlobalName
|
|
125
|
-
}
|
|
126
|
-
global[config.registerGlobal] = setCommentString
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return setCommentString
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function getRootMetaStep(step) {
|
|
133
|
-
if (step.metaStep) return getRootMetaStep(step.metaStep)
|
|
134
|
-
return step
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function setCommentString(string) {
|
|
138
|
-
recorder.add('set comment metastep', () => {
|
|
139
|
-
currentCommentStep = new MetaStep(String.raw(string), '')
|
|
140
|
-
})
|
|
141
|
-
}
|