codeceptjs 4.0.0-beta.3 → 4.0.0-beta.5
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 +134 -119
- package/bin/codecept.js +12 -2
- package/bin/test-server.js +53 -0
- package/docs/webapi/clearCookie.mustache +1 -1
- package/lib/actor.js +66 -102
- package/lib/ai.js +130 -121
- package/lib/assert/empty.js +3 -5
- package/lib/assert/equal.js +4 -7
- package/lib/assert/include.js +4 -6
- package/lib/assert/throws.js +2 -4
- package/lib/assert/truth.js +2 -2
- package/lib/codecept.js +141 -86
- package/lib/command/check.js +201 -0
- package/lib/command/configMigrate.js +2 -4
- package/lib/command/definitions.js +8 -26
- package/lib/command/dryRun.js +30 -35
- package/lib/command/generate.js +10 -14
- package/lib/command/gherkin/snippets.js +75 -73
- package/lib/command/gherkin/steps.js +1 -1
- package/lib/command/info.js +42 -8
- package/lib/command/init.js +13 -12
- package/lib/command/interactive.js +10 -2
- package/lib/command/list.js +1 -1
- package/lib/command/run-multiple/chunk.js +48 -45
- package/lib/command/run-multiple.js +12 -35
- package/lib/command/run-workers.js +21 -58
- package/lib/command/utils.js +5 -6
- package/lib/command/workers/runTests.js +263 -222
- package/lib/container.js +386 -238
- package/lib/data/context.js +10 -13
- package/lib/data/dataScenarioConfig.js +8 -8
- package/lib/data/dataTableArgument.js +6 -6
- package/lib/data/table.js +5 -11
- package/lib/effects.js +223 -0
- package/lib/element/WebElement.js +327 -0
- package/lib/els.js +158 -0
- package/lib/event.js +21 -17
- package/lib/heal.js +88 -80
- package/lib/helper/AI.js +2 -1
- package/lib/helper/ApiDataFactory.js +4 -7
- package/lib/helper/Appium.js +50 -57
- package/lib/helper/FileSystem.js +3 -3
- package/lib/helper/GraphQLDataFactory.js +4 -4
- package/lib/helper/JSONResponse.js +75 -37
- package/lib/helper/Mochawesome.js +31 -9
- package/lib/helper/Nightmare.js +37 -58
- package/lib/helper/Playwright.js +267 -272
- package/lib/helper/Protractor.js +56 -87
- package/lib/helper/Puppeteer.js +247 -264
- package/lib/helper/REST.js +29 -17
- package/lib/helper/TestCafe.js +22 -47
- package/lib/helper/WebDriver.js +157 -368
- package/lib/helper/extras/PlaywrightPropEngine.js +2 -2
- package/lib/helper/extras/Popup.js +22 -22
- package/lib/helper/network/utils.js +1 -1
- package/lib/helper/testcafe/testcafe-utils.js +27 -28
- package/lib/listener/emptyRun.js +55 -0
- package/lib/listener/exit.js +7 -10
- package/lib/listener/{retry.js → globalRetry.js} +5 -5
- package/lib/listener/globalTimeout.js +165 -0
- package/lib/listener/helpers.js +15 -15
- package/lib/listener/mocha.js +1 -1
- package/lib/listener/result.js +12 -0
- package/lib/listener/retryEnhancer.js +85 -0
- package/lib/listener/steps.js +32 -18
- package/lib/listener/store.js +20 -0
- package/lib/locator.js +1 -1
- package/lib/mocha/asyncWrapper.js +231 -0
- package/lib/{interfaces → mocha}/bdd.js +3 -3
- package/lib/mocha/cli.js +308 -0
- package/lib/mocha/factory.js +104 -0
- package/lib/{interfaces → mocha}/featureConfig.js +32 -12
- package/lib/{interfaces → mocha}/gherkin.js +26 -28
- package/lib/mocha/hooks.js +112 -0
- package/lib/mocha/index.js +12 -0
- package/lib/mocha/inject.js +29 -0
- package/lib/{interfaces → mocha}/scenarioConfig.js +31 -7
- package/lib/mocha/suite.js +82 -0
- package/lib/mocha/test.js +181 -0
- package/lib/mocha/types.d.ts +42 -0
- package/lib/mocha/ui.js +232 -0
- package/lib/output.js +93 -65
- package/lib/pause.js +160 -138
- package/lib/plugin/analyze.js +396 -0
- package/lib/plugin/auth.js +435 -0
- package/lib/plugin/autoDelay.js +8 -8
- package/lib/plugin/autoLogin.js +3 -338
- package/lib/plugin/commentStep.js +6 -1
- package/lib/plugin/coverage.js +10 -22
- package/lib/plugin/customLocator.js +3 -3
- package/lib/plugin/customReporter.js +52 -0
- package/lib/plugin/eachElement.js +1 -1
- package/lib/plugin/fakerTransform.js +1 -1
- package/lib/plugin/heal.js +36 -9
- package/lib/plugin/htmlReporter.js +1947 -0
- package/lib/plugin/pageInfo.js +140 -0
- package/lib/plugin/retryFailedStep.js +17 -18
- package/lib/plugin/retryTo.js +2 -113
- package/lib/plugin/screenshotOnFail.js +17 -58
- package/lib/plugin/selenoid.js +15 -35
- package/lib/plugin/standardActingHelpers.js +4 -1
- package/lib/plugin/stepByStepReport.js +56 -17
- package/lib/plugin/stepTimeout.js +5 -12
- package/lib/plugin/subtitles.js +4 -4
- package/lib/plugin/tryTo.js +3 -102
- package/lib/plugin/wdio.js +8 -10
- package/lib/recorder.js +155 -124
- package/lib/rerun.js +43 -42
- package/lib/result.js +161 -0
- package/lib/secret.js +1 -2
- package/lib/step/base.js +239 -0
- package/lib/step/comment.js +10 -0
- package/lib/step/config.js +50 -0
- package/lib/step/func.js +46 -0
- package/lib/step/helper.js +50 -0
- package/lib/step/meta.js +99 -0
- package/lib/step/record.js +74 -0
- package/lib/step/retry.js +11 -0
- package/lib/step/section.js +55 -0
- package/lib/step.js +21 -332
- package/lib/steps.js +50 -0
- package/lib/store.js +37 -5
- package/lib/template/heal.js +2 -11
- package/lib/test-server.js +323 -0
- package/lib/timeout.js +66 -0
- package/lib/utils.js +351 -218
- package/lib/within.js +75 -55
- package/lib/workerStorage.js +2 -1
- package/lib/workers.js +386 -277
- package/package.json +81 -75
- package/translations/de-DE.js +5 -3
- package/translations/fr-FR.js +5 -4
- package/translations/index.js +1 -0
- package/translations/it-IT.js +4 -3
- package/translations/ja-JP.js +4 -3
- package/translations/nl-NL.js +76 -0
- package/translations/pl-PL.js +4 -3
- package/translations/pt-BR.js +4 -3
- package/translations/ru-RU.js +4 -3
- package/translations/utils.js +9 -0
- package/translations/zh-CN.js +4 -3
- package/translations/zh-TW.js +4 -3
- package/typings/index.d.ts +197 -187
- package/typings/promiseBasedTypes.d.ts +53 -903
- package/typings/types.d.ts +372 -1042
- package/lib/cli.js +0 -257
- package/lib/helper/ExpectHelper.js +0 -391
- package/lib/helper/MockServer.js +0 -221
- package/lib/helper/SoftExpectHelper.js +0 -381
- package/lib/listener/artifacts.js +0 -19
- package/lib/listener/timeout.js +0 -109
- package/lib/mochaFactory.js +0 -113
- package/lib/plugin/debugErrors.js +0 -67
- package/lib/scenario.js +0 -224
- package/lib/ui.js +0 -236
package/lib/ui.js
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
const escapeRe = require('escape-string-regexp');
|
|
2
|
-
const Suite = require('mocha/lib/suite');
|
|
3
|
-
const Test = require('mocha/lib/test');
|
|
4
|
-
|
|
5
|
-
const scenario = require('./scenario');
|
|
6
|
-
const ScenarioConfig = require('./interfaces/scenarioConfig');
|
|
7
|
-
const FeatureConfig = require('./interfaces/featureConfig');
|
|
8
|
-
const addDataContext = require('./data/context');
|
|
9
|
-
const container = require('./container');
|
|
10
|
-
|
|
11
|
-
const setContextTranslation = (context) => {
|
|
12
|
-
const contexts = container.translation().value('contexts');
|
|
13
|
-
|
|
14
|
-
if (contexts) {
|
|
15
|
-
for (const key of Object.keys(contexts)) {
|
|
16
|
-
if (context[key]) {
|
|
17
|
-
context[contexts[key]] = context[key];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Codecept-style interface:
|
|
25
|
-
*
|
|
26
|
-
* Feature('login');
|
|
27
|
-
*
|
|
28
|
-
* Scenario('login as regular user', ({I}) {
|
|
29
|
-
* I.fillField();
|
|
30
|
-
* I.click();
|
|
31
|
-
* I.see('Hello, '+data.login);
|
|
32
|
-
* });
|
|
33
|
-
*
|
|
34
|
-
* @param {Mocha.Suite} suite Root suite.
|
|
35
|
-
* @ignore
|
|
36
|
-
*/
|
|
37
|
-
module.exports = function (suite) {
|
|
38
|
-
const suites = [suite];
|
|
39
|
-
suite.timeout(0);
|
|
40
|
-
let afterAllHooks;
|
|
41
|
-
let afterEachHooks;
|
|
42
|
-
let afterAllHooksAreLoaded;
|
|
43
|
-
let afterEachHooksAreLoaded;
|
|
44
|
-
|
|
45
|
-
suite.on('pre-require', (context, file, mocha) => {
|
|
46
|
-
const common = require('mocha/lib/interfaces/common')(suites, context, mocha);
|
|
47
|
-
|
|
48
|
-
const addScenario = function (title, opts = {}, fn) {
|
|
49
|
-
const suite = suites[0];
|
|
50
|
-
|
|
51
|
-
if (typeof opts === 'function' && !fn) {
|
|
52
|
-
fn = opts;
|
|
53
|
-
opts = {};
|
|
54
|
-
}
|
|
55
|
-
if (suite.pending) {
|
|
56
|
-
fn = null;
|
|
57
|
-
}
|
|
58
|
-
const test = new Test(title, fn);
|
|
59
|
-
test.fullTitle = () => `${suite.title}: ${test.title}`;
|
|
60
|
-
|
|
61
|
-
test.tags = (suite.tags || []).concat(title.match(/(\@[a-zA-Z0-9-_]+)/g) || []); // match tags from title
|
|
62
|
-
test.file = file;
|
|
63
|
-
if (!test.inject) {
|
|
64
|
-
test.inject = {};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
suite.addTest(scenario.test(test));
|
|
68
|
-
if (opts.retries) test.retries(opts.retries);
|
|
69
|
-
if (opts.timeout) test.totalTimeout = opts.timeout;
|
|
70
|
-
test.opts = opts;
|
|
71
|
-
|
|
72
|
-
return new ScenarioConfig(test);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// create dispatcher
|
|
76
|
-
|
|
77
|
-
context.BeforeAll = common.before;
|
|
78
|
-
context.AfterAll = common.after;
|
|
79
|
-
|
|
80
|
-
context.run = mocha.options.delay && common.runWithSuite(suite);
|
|
81
|
-
/**
|
|
82
|
-
* Describe a "suite" with the given `title`
|
|
83
|
-
* and callback `fn` containing nested suites
|
|
84
|
-
* and/or tests.
|
|
85
|
-
* @global
|
|
86
|
-
* @param {string} title
|
|
87
|
-
* @param {Object<string, *>} [opts]
|
|
88
|
-
* @returns {FeatureConfig}
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
context.Feature = function (title, opts) {
|
|
92
|
-
if (suites.length > 1) {
|
|
93
|
-
suites.shift();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
afterAllHooks = [];
|
|
97
|
-
afterEachHooks = [];
|
|
98
|
-
afterAllHooksAreLoaded = false;
|
|
99
|
-
afterEachHooksAreLoaded = false;
|
|
100
|
-
|
|
101
|
-
const suite = Suite.create(suites[0], title);
|
|
102
|
-
if (!opts) opts = {};
|
|
103
|
-
suite.opts = opts;
|
|
104
|
-
suite.timeout(0);
|
|
105
|
-
|
|
106
|
-
if (opts.retries) suite.retries(opts.retries);
|
|
107
|
-
if (opts.timeout) suite.totalTimeout = opts.timeout;
|
|
108
|
-
|
|
109
|
-
suite.tags = title.match(/(\@[a-zA-Z0-9-_]+)/g) || []; // match tags from title
|
|
110
|
-
suite.file = file;
|
|
111
|
-
suite.fullTitle = () => `${suite.title}:`;
|
|
112
|
-
suites.unshift(suite);
|
|
113
|
-
suite.beforeEach('codeceptjs.before', () => scenario.setup(suite));
|
|
114
|
-
afterEachHooks.push(['finalize codeceptjs', () => scenario.teardown(suite)]);
|
|
115
|
-
|
|
116
|
-
suite.beforeAll('codeceptjs.beforeSuite', () => scenario.suiteSetup(suite));
|
|
117
|
-
afterAllHooks.push(['codeceptjs.afterSuite', () => scenario.suiteTeardown(suite)]);
|
|
118
|
-
|
|
119
|
-
if (opts.skipInfo && opts.skipInfo.skipped) {
|
|
120
|
-
suite.pending = true;
|
|
121
|
-
suite.opts = { ...suite.opts, skipInfo: opts.skipInfo };
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return new FeatureConfig(suite);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Pending test suite.
|
|
129
|
-
* @global
|
|
130
|
-
* @kind constant
|
|
131
|
-
* @type {CodeceptJS.IFeature}
|
|
132
|
-
*/
|
|
133
|
-
context.xFeature = context.Feature.skip = function (title, opts) {
|
|
134
|
-
const skipInfo = {
|
|
135
|
-
skipped: true,
|
|
136
|
-
message: 'Skipped due to "skip" on Feature.',
|
|
137
|
-
};
|
|
138
|
-
return context.Feature(title, { ...opts, skipInfo });
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
context.BeforeSuite = function (fn) {
|
|
142
|
-
suites[0].beforeAll('BeforeSuite', scenario.injected(fn, suites[0], 'beforeSuite'));
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
context.AfterSuite = function (fn) {
|
|
146
|
-
afterAllHooks.unshift(['AfterSuite', scenario.injected(fn, suites[0], 'afterSuite')]);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
context.Background = context.Before = function (fn) {
|
|
150
|
-
suites[0].beforeEach('Before', scenario.injected(fn, suites[0], 'before'));
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
context.After = function (fn) {
|
|
154
|
-
afterEachHooks.unshift(['After', scenario.injected(fn, suites[0], 'after')]);
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Describe a specification or test-case
|
|
159
|
-
* with the given `title` and callback `fn`
|
|
160
|
-
* acting as a thunk.
|
|
161
|
-
* @ignore
|
|
162
|
-
*/
|
|
163
|
-
context.Scenario = addScenario;
|
|
164
|
-
/**
|
|
165
|
-
* Exclusive test-case.
|
|
166
|
-
* @ignore
|
|
167
|
-
*/
|
|
168
|
-
context.Scenario.only = function (title, opts, fn) {
|
|
169
|
-
const reString = `^${escapeRe(`${suites[0].title}: ${title}`.replace(/( \| {.+})?$/g, ''))}`;
|
|
170
|
-
mocha.grep(new RegExp(reString));
|
|
171
|
-
process.env.SCENARIO_ONLY = true;
|
|
172
|
-
return addScenario(title, opts, fn);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Pending test case.
|
|
177
|
-
* @global
|
|
178
|
-
* @kind constant
|
|
179
|
-
* @type {CodeceptJS.IScenario}
|
|
180
|
-
*/
|
|
181
|
-
context.xScenario = context.Scenario.skip = function (title, opts = {}, fn) {
|
|
182
|
-
if (typeof opts === 'function' && !fn) {
|
|
183
|
-
opts = {};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return context.Scenario(title, opts);
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Pending test case with message: 'Test not implemented!'.
|
|
191
|
-
* @global
|
|
192
|
-
* @kind constant
|
|
193
|
-
* @type {CodeceptJS.IScenario}
|
|
194
|
-
*/
|
|
195
|
-
context.Scenario.todo = function (title, opts = {}, fn) {
|
|
196
|
-
if (typeof opts === 'function' && !fn) {
|
|
197
|
-
fn = opts;
|
|
198
|
-
opts = {};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const skipInfo = {
|
|
202
|
-
message: 'Test not implemented!',
|
|
203
|
-
description: fn ? fn.toString() : '',
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
return context.Scenario(title, { ...opts, skipInfo });
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* For translation
|
|
211
|
-
*/
|
|
212
|
-
|
|
213
|
-
setContextTranslation(context);
|
|
214
|
-
|
|
215
|
-
addDataContext(context);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
suite.on('post-require', () => {
|
|
219
|
-
/**
|
|
220
|
-
* load hooks from arrays to suite to prevent reordering
|
|
221
|
-
*/
|
|
222
|
-
if (!afterEachHooksAreLoaded && Array.isArray(afterEachHooks)) {
|
|
223
|
-
afterEachHooks.forEach((hook) => {
|
|
224
|
-
suites[0].afterEach(hook[0], hook[1]);
|
|
225
|
-
});
|
|
226
|
-
afterEachHooksAreLoaded = true;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (!afterAllHooksAreLoaded && Array.isArray(afterAllHooks)) {
|
|
230
|
-
afterAllHooks.forEach((hook) => {
|
|
231
|
-
suites[0].afterAll(hook[0], hook[1]);
|
|
232
|
-
});
|
|
233
|
-
afterAllHooksAreLoaded = true;
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
};
|