codeceptjs 3.7.0-beta.12 → 3.7.0-beta.13
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/lib/codecept.js +12 -14
- package/lib/command/check.js +2 -11
- package/lib/command/definitions.js +1 -1
- package/lib/command/gherkin/snippets.js +69 -69
- package/lib/command/interactive.js +1 -1
- package/lib/command/run-multiple/chunk.js +45 -48
- package/lib/container.js +7 -14
- package/lib/helper/AI.js +1 -2
- package/lib/mocha/asyncWrapper.js +1 -3
- package/lib/mocha/gherkin.js +1 -1
- package/lib/mocha/inject.js +0 -5
- package/lib/plugin/autoDelay.js +2 -2
- package/lib/plugin/autoLogin.js +337 -3
- package/lib/plugin/pageInfo.js +1 -1
- package/lib/plugin/retryTo.js +6 -17
- package/lib/plugin/screenshotOnFail.js +1 -1
- package/lib/plugin/standardActingHelpers.js +1 -4
- package/lib/plugin/stepByStepReport.js +1 -1
- package/lib/plugin/tryTo.js +6 -15
- package/lib/step/base.js +2 -7
- package/package.json +13 -12
- package/translations/de-DE.js +3 -4
- package/translations/fr-FR.js +3 -4
- package/translations/index.js +0 -1
- package/translations/it-IT.js +3 -4
- package/translations/ja-JP.js +3 -4
- package/translations/pl-PL.js +3 -4
- package/translations/pt-BR.js +3 -4
- package/translations/ru-RU.js +3 -4
- package/translations/zh-CN.js +3 -4
- package/translations/zh-TW.js +3 -4
- package/typings/promiseBasedTypes.d.ts +18 -506
- package/typings/types.d.ts +23 -511
- package/lib/plugin/auth.js +0 -435
- package/lib/step/comment.js +0 -10
- package/translations/nl-NL.js +0 -76
- package/translations/utils.js +0 -9
package/lib/codecept.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { existsSync, readFileSync } = require('fs')
|
|
2
|
-
const
|
|
2
|
+
const glob = require('glob')
|
|
3
3
|
const fsPath = require('path')
|
|
4
4
|
const { resolve } = require('path')
|
|
5
5
|
|
|
@@ -168,17 +168,15 @@ class Codecept {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
for (pattern of patterns) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
})
|
|
181
|
-
}
|
|
171
|
+
glob.sync(pattern, options).forEach(file => {
|
|
172
|
+
if (file.includes('node_modules')) return
|
|
173
|
+
if (!fsPath.isAbsolute(file)) {
|
|
174
|
+
file = fsPath.join(global.codecept_dir, file)
|
|
175
|
+
}
|
|
176
|
+
if (!this.testFiles.includes(fsPath.resolve(file))) {
|
|
177
|
+
this.testFiles.push(fsPath.resolve(file))
|
|
178
|
+
}
|
|
179
|
+
})
|
|
182
180
|
}
|
|
183
181
|
}
|
|
184
182
|
|
|
@@ -202,12 +200,12 @@ class Codecept {
|
|
|
202
200
|
}
|
|
203
201
|
const done = () => {
|
|
204
202
|
event.emit(event.all.result, container.result())
|
|
205
|
-
event.emit(event.all.after
|
|
203
|
+
event.emit(event.all.after)
|
|
206
204
|
resolve()
|
|
207
205
|
}
|
|
208
206
|
|
|
209
207
|
try {
|
|
210
|
-
event.emit(event.all.before
|
|
208
|
+
event.emit(event.all.before)
|
|
211
209
|
mocha.run(() => done())
|
|
212
210
|
} catch (e) {
|
|
213
211
|
output.error(e.stack)
|
package/lib/command/check.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { getConfig, getTestRoot } = require('./utils')
|
|
2
2
|
const Codecept = require('../codecept')
|
|
3
3
|
const output = require('../output')
|
|
4
|
+
const standardActingHelpers = require('../plugin/standardActingHelpers')
|
|
4
5
|
const store = require('../store')
|
|
5
6
|
const container = require('../container')
|
|
6
7
|
const figures = require('figures')
|
|
@@ -22,7 +23,6 @@ module.exports = async function (options) {
|
|
|
22
23
|
container: false,
|
|
23
24
|
pageObjects: false,
|
|
24
25
|
plugins: false,
|
|
25
|
-
ai: true, // we don't need to check AI
|
|
26
26
|
helpers: false,
|
|
27
27
|
setup: false,
|
|
28
28
|
tests: false,
|
|
@@ -51,8 +51,6 @@ module.exports = async function (options) {
|
|
|
51
51
|
checks.container = err
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const standardActingHelpers = container.STANDARD_ACTING_HELPERS
|
|
55
|
-
|
|
56
54
|
printCheck('container', checks['container'])
|
|
57
55
|
|
|
58
56
|
if (codecept) {
|
|
@@ -85,13 +83,6 @@ module.exports = async function (options) {
|
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
if (config?.ai?.request) {
|
|
89
|
-
checks.ai = true
|
|
90
|
-
printCheck('ai', checks['ai'], 'AI configuration is enabled, request function is set')
|
|
91
|
-
} else {
|
|
92
|
-
printCheck('ai', checks['ai'], 'AI is disabled')
|
|
93
|
-
}
|
|
94
|
-
|
|
95
86
|
printCheck('tests', checks['tests'], `Total: ${numTests} tests`)
|
|
96
87
|
|
|
97
88
|
store.dryRun = true
|
|
@@ -179,7 +170,7 @@ function printCheck(name, value, comment = '') {
|
|
|
179
170
|
}
|
|
180
171
|
|
|
181
172
|
if (value instanceof Error) {
|
|
182
|
-
comment = `${comment} ${chalk.red(value.message)}`.trim()
|
|
173
|
+
comment = `${comment} ${chalk.red.italic(value.message)}`.trim()
|
|
183
174
|
}
|
|
184
175
|
|
|
185
176
|
output.print(status, name.toUpperCase(), chalk.dim(comment))
|
|
@@ -5,7 +5,7 @@ const { getConfig, getTestRoot } = require('./utils')
|
|
|
5
5
|
const Codecept = require('../codecept')
|
|
6
6
|
const container = require('../container')
|
|
7
7
|
const output = require('../output')
|
|
8
|
-
const actingHelpers = [...
|
|
8
|
+
const actingHelpers = [...require('../plugin/standardActingHelpers'), 'REST']
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Prepare data and generate content of definitions file
|
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
const escapeStringRegexp = require('escape-string-regexp')
|
|
2
|
-
const fs = require('fs')
|
|
3
|
-
const Gherkin = require('@cucumber/gherkin')
|
|
4
|
-
const Messages = require('@cucumber/messages')
|
|
5
|
-
const
|
|
6
|
-
const fsPath = require('path')
|
|
1
|
+
const escapeStringRegexp = require('escape-string-regexp');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const Gherkin = require('@cucumber/gherkin');
|
|
4
|
+
const Messages = require('@cucumber/messages');
|
|
5
|
+
const glob = require('glob');
|
|
6
|
+
const fsPath = require('path');
|
|
7
7
|
|
|
8
|
-
const { getConfig, getTestRoot } = require('../utils')
|
|
9
|
-
const Codecept = require('../../codecept')
|
|
10
|
-
const output = require('../../output')
|
|
11
|
-
const { matchStep } = require('../../mocha/bdd')
|
|
8
|
+
const { getConfig, getTestRoot } = require('../utils');
|
|
9
|
+
const Codecept = require('../../codecept');
|
|
10
|
+
const output = require('../../output');
|
|
11
|
+
const { matchStep } = require('../../mocha/bdd');
|
|
12
12
|
|
|
13
|
-
const uuidFn = Messages.IdGenerator.uuid()
|
|
14
|
-
const builder = new Gherkin.AstBuilder(uuidFn)
|
|
15
|
-
const matcher = new Gherkin.GherkinClassicTokenMatcher()
|
|
16
|
-
const parser = new Gherkin.Parser(builder, matcher)
|
|
17
|
-
parser.stopAtFirstError = false
|
|
13
|
+
const uuidFn = Messages.IdGenerator.uuid();
|
|
14
|
+
const builder = new Gherkin.AstBuilder(uuidFn);
|
|
15
|
+
const matcher = new Gherkin.GherkinClassicTokenMatcher();
|
|
16
|
+
const parser = new Gherkin.Parser(builder, matcher);
|
|
17
|
+
parser.stopAtFirstError = false;
|
|
18
18
|
|
|
19
19
|
module.exports = function (genPath, options) {
|
|
20
|
-
const configFile = options.config || genPath
|
|
21
|
-
const testsPath = getTestRoot(configFile)
|
|
22
|
-
const config = getConfig(configFile)
|
|
23
|
-
if (!config) return
|
|
20
|
+
const configFile = options.config || genPath;
|
|
21
|
+
const testsPath = getTestRoot(configFile);
|
|
22
|
+
const config = getConfig(configFile);
|
|
23
|
+
if (!config) return;
|
|
24
24
|
|
|
25
|
-
const codecept = new Codecept(config, {})
|
|
26
|
-
codecept.init(testsPath)
|
|
25
|
+
const codecept = new Codecept(config, {});
|
|
26
|
+
codecept.init(testsPath);
|
|
27
27
|
|
|
28
28
|
if (!config.gherkin) {
|
|
29
|
-
output.error('Gherkin is not enabled in config. Run `codecept gherkin:init` to enable it')
|
|
30
|
-
process.exit(1)
|
|
29
|
+
output.error('Gherkin is not enabled in config. Run `codecept gherkin:init` to enable it');
|
|
30
|
+
process.exit(1);
|
|
31
31
|
}
|
|
32
32
|
if (!config.gherkin.steps || !config.gherkin.steps[0]) {
|
|
33
|
-
output.error('No gherkin steps defined in config. Exiting')
|
|
34
|
-
process.exit(1)
|
|
33
|
+
output.error('No gherkin steps defined in config. Exiting');
|
|
34
|
+
process.exit(1);
|
|
35
35
|
}
|
|
36
36
|
if (!options.feature && !config.gherkin.features) {
|
|
37
|
-
output.error('No gherkin features defined in config. Exiting')
|
|
38
|
-
process.exit(1)
|
|
37
|
+
output.error('No gherkin features defined in config. Exiting');
|
|
38
|
+
process.exit(1);
|
|
39
39
|
}
|
|
40
40
|
if (options.path && !config.gherkin.steps.includes(options.path)) {
|
|
41
|
-
output.error(`You must include ${options.path} to the gherkin steps in your config file`)
|
|
42
|
-
process.exit(1)
|
|
41
|
+
output.error(`You must include ${options.path} to the gherkin steps in your config file`);
|
|
42
|
+
process.exit(1);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const files = []
|
|
46
|
-
|
|
45
|
+
const files = [];
|
|
46
|
+
glob.sync(options.feature || config.gherkin.features, { cwd: options.feature ? '.' : global.codecept_dir }).forEach(file => {
|
|
47
47
|
if (!fsPath.isAbsolute(file)) {
|
|
48
|
-
file = fsPath.join(global.codecept_dir, file)
|
|
48
|
+
file = fsPath.join(global.codecept_dir, file);
|
|
49
49
|
}
|
|
50
|
-
files.push(fsPath.resolve(file))
|
|
51
|
-
})
|
|
52
|
-
output.print(`Loaded ${files.length} files`)
|
|
50
|
+
files.push(fsPath.resolve(file));
|
|
51
|
+
});
|
|
52
|
+
output.print(`Loaded ${files.length} files`);
|
|
53
53
|
|
|
54
|
-
const newSteps = new Map()
|
|
54
|
+
const newSteps = new Map();
|
|
55
55
|
|
|
56
56
|
const parseSteps = steps => {
|
|
57
|
-
const newSteps = []
|
|
58
|
-
let currentKeyword = ''
|
|
57
|
+
const newSteps = [];
|
|
58
|
+
let currentKeyword = '';
|
|
59
59
|
for (const step of steps) {
|
|
60
60
|
if (step.keyword.trim() === 'And') {
|
|
61
|
-
if (!currentKeyword) throw new Error(`There is no active keyword for step '${step.text}'`)
|
|
62
|
-
step.keyword = currentKeyword
|
|
61
|
+
if (!currentKeyword) throw new Error(`There is no active keyword for step '${step.text}'`);
|
|
62
|
+
step.keyword = currentKeyword;
|
|
63
63
|
}
|
|
64
|
-
currentKeyword = step.keyword
|
|
64
|
+
currentKeyword = step.keyword;
|
|
65
65
|
try {
|
|
66
|
-
matchStep(step.text)
|
|
66
|
+
matchStep(step.text);
|
|
67
67
|
} catch (err) {
|
|
68
|
-
let stepLine
|
|
68
|
+
let stepLine;
|
|
69
69
|
if (/[{}()/]/.test(step.text)) {
|
|
70
70
|
stepLine = escapeStringRegexp(step.text)
|
|
71
71
|
.replace(/\//g, '\\/')
|
|
72
72
|
.replace(/\"(.*?)\"/g, '"(.*?)"')
|
|
73
73
|
.replace(/(\d+\\\.\d+)/, '(\\d+\\.\\d+)')
|
|
74
|
-
.replace(/ (\d+) /, ' (\\d+) ')
|
|
75
|
-
stepLine = Object.assign(stepLine, { type: step.keyword.trim(), location: step.location, regexp: true })
|
|
74
|
+
.replace(/ (\d+) /, ' (\\d+) ');
|
|
75
|
+
stepLine = Object.assign(stepLine, { type: step.keyword.trim(), location: step.location, regexp: true });
|
|
76
76
|
} else {
|
|
77
77
|
stepLine = step.text
|
|
78
78
|
.replace(/\"(.*?)\"/g, '{string}')
|
|
79
79
|
.replace(/(\d+\.\d+)/, '{float}')
|
|
80
|
-
.replace(/ (\d+) /, ' {int} ')
|
|
81
|
-
stepLine = Object.assign(stepLine, { type: step.keyword.trim(), location: step.location, regexp: false })
|
|
80
|
+
.replace(/ (\d+) /, ' {int} ');
|
|
81
|
+
stepLine = Object.assign(stepLine, { type: step.keyword.trim(), location: step.location, regexp: false });
|
|
82
82
|
}
|
|
83
|
-
newSteps.push(stepLine)
|
|
83
|
+
newSteps.push(stepLine);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
return newSteps
|
|
87
|
-
}
|
|
86
|
+
return newSteps;
|
|
87
|
+
};
|
|
88
88
|
|
|
89
89
|
const parseFile = file => {
|
|
90
|
-
const ast = parser.parse(fs.readFileSync(file).toString())
|
|
90
|
+
const ast = parser.parse(fs.readFileSync(file).toString());
|
|
91
91
|
for (const child of ast.feature.children) {
|
|
92
|
-
if (child.scenario.keyword === 'Scenario Outline') continue // skip scenario outline
|
|
92
|
+
if (child.scenario.keyword === 'Scenario Outline') continue; // skip scenario outline
|
|
93
93
|
parseSteps(child.scenario.steps)
|
|
94
94
|
.map(step => {
|
|
95
|
-
return Object.assign(step, { file: file.replace(global.codecept_dir, '').slice(1) })
|
|
95
|
+
return Object.assign(step, { file: file.replace(global.codecept_dir, '').slice(1) });
|
|
96
96
|
})
|
|
97
|
-
.map(step => newSteps.set(`${step.type}(${step})`, step))
|
|
97
|
+
.map(step => newSteps.set(`${step.type}(${step})`, step));
|
|
98
98
|
}
|
|
99
|
-
}
|
|
99
|
+
};
|
|
100
100
|
|
|
101
|
-
files.forEach(file => parseFile(file))
|
|
101
|
+
files.forEach(file => parseFile(file));
|
|
102
102
|
|
|
103
|
-
let stepFile = options.path || config.gherkin.steps[0]
|
|
103
|
+
let stepFile = options.path || config.gherkin.steps[0];
|
|
104
104
|
if (!fs.existsSync(stepFile)) {
|
|
105
|
-
output.error(`Please enter a valid step file path ${stepFile}`)
|
|
106
|
-
process.exit(1)
|
|
105
|
+
output.error(`Please enter a valid step file path ${stepFile}`);
|
|
106
|
+
process.exit(1);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
if (!fsPath.isAbsolute(stepFile)) {
|
|
110
|
-
stepFile = fsPath.join(global.codecept_dir, stepFile)
|
|
110
|
+
stepFile = fsPath.join(global.codecept_dir, stepFile);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
const snippets = [...newSteps.values()]
|
|
@@ -117,18 +117,18 @@ module.exports = function (genPath, options) {
|
|
|
117
117
|
${step.type}(${step.regexp ? '/^' : "'"}${step}${step.regexp ? '$/' : "'"}, () => {
|
|
118
118
|
// From "${step.file}" ${JSON.stringify(step.location)}
|
|
119
119
|
throw new Error('Not implemented yet');
|
|
120
|
-
})
|
|
121
|
-
})
|
|
120
|
+
});`;
|
|
121
|
+
});
|
|
122
122
|
|
|
123
123
|
if (!snippets.length) {
|
|
124
|
-
output.print('No new snippets found')
|
|
125
|
-
return
|
|
124
|
+
output.print('No new snippets found');
|
|
125
|
+
return;
|
|
126
126
|
}
|
|
127
|
-
output.success(`Snippets generated: ${snippets.length}`)
|
|
128
|
-
output.print(snippets.join('\n'))
|
|
127
|
+
output.success(`Snippets generated: ${snippets.length}`);
|
|
128
|
+
output.print(snippets.join('\n'));
|
|
129
129
|
|
|
130
130
|
if (!options.dryRun) {
|
|
131
|
-
output.success(`Snippets added to ${output.colors.bold(stepFile)}`)
|
|
132
|
-
fs.writeFileSync(stepFile, fs.readFileSync(stepFile).toString() + snippets.join('\n') + '\n')
|
|
131
|
+
output.success(`Snippets added to ${output.colors.bold(stepFile)}`);
|
|
132
|
+
fs.writeFileSync(stepFile, fs.readFileSync(stepFile).toString() + snippets.join('\n') + '\n');
|
|
133
133
|
}
|
|
134
|
-
}
|
|
134
|
+
};
|
|
@@ -4,7 +4,7 @@ const Codecept = require('../codecept')
|
|
|
4
4
|
const Container = require('../container')
|
|
5
5
|
const event = require('../event')
|
|
6
6
|
const output = require('../output')
|
|
7
|
-
const webHelpers =
|
|
7
|
+
const webHelpers = require('../plugin/standardActingHelpers')
|
|
8
8
|
|
|
9
9
|
module.exports = async function (path, options) {
|
|
10
10
|
// Backward compatibility for --profile
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
const
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const fs = require('fs')
|
|
1
|
+
const glob = require('glob');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Splits a list to (n) parts, defined via the size argument.
|
|
7
7
|
*/
|
|
8
8
|
const splitFiles = (list, size) => {
|
|
9
|
-
const sets = []
|
|
10
|
-
const chunks = list.length / size
|
|
11
|
-
let i = 0
|
|
9
|
+
const sets = [];
|
|
10
|
+
const chunks = list.length / size;
|
|
11
|
+
let i = 0;
|
|
12
12
|
|
|
13
13
|
while (i < chunks) {
|
|
14
|
-
sets[i] = list.splice(0, size)
|
|
15
|
-
i
|
|
14
|
+
sets[i] = list.splice(0, size);
|
|
15
|
+
i++;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
return sets
|
|
19
|
-
}
|
|
18
|
+
return sets;
|
|
19
|
+
};
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Executes a glob pattern and pushes the results to a list.
|
|
23
23
|
*/
|
|
24
|
-
const findFiles = pattern => {
|
|
25
|
-
const files = []
|
|
24
|
+
const findFiles = (pattern) => {
|
|
25
|
+
const files = [];
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
files.push(path.resolve(file))
|
|
29
|
-
})
|
|
27
|
+
glob.sync(pattern).forEach((file) => {
|
|
28
|
+
files.push(path.resolve(file));
|
|
29
|
+
});
|
|
30
30
|
|
|
31
|
-
return files
|
|
32
|
-
}
|
|
31
|
+
return files;
|
|
32
|
+
};
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Joins a list of files to a valid glob pattern
|
|
36
36
|
*/
|
|
37
|
-
const flattenFiles = list => {
|
|
38
|
-
const pattern = list.join(',')
|
|
39
|
-
return pattern.indexOf(',') > -1 ? `{${pattern}}` : pattern
|
|
40
|
-
}
|
|
37
|
+
const flattenFiles = (list) => {
|
|
38
|
+
const pattern = list.join(',');
|
|
39
|
+
return pattern.indexOf(',') > -1 ? `{${pattern}}` : pattern;
|
|
40
|
+
};
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Greps a file by its content, checks if Scenario or Feature text'
|
|
44
44
|
* matches the grep text.
|
|
45
45
|
*/
|
|
46
46
|
const grepFile = (file, grep) => {
|
|
47
|
-
const contents = fs.readFileSync(file, 'utf8')
|
|
48
|
-
const pattern = new RegExp(`((Scenario|Feature)\(.*${grep}.*\))`, 'g') // <- How future proof/solid is this?
|
|
49
|
-
return !!pattern.exec(contents)
|
|
50
|
-
}
|
|
47
|
+
const contents = fs.readFileSync(file, 'utf8');
|
|
48
|
+
const pattern = new RegExp(`((Scenario|Feature)\(.*${grep}.*\))`, 'g'); // <- How future proof/solid is this?
|
|
49
|
+
return !!pattern.exec(contents);
|
|
50
|
+
};
|
|
51
51
|
|
|
52
|
-
const mapFileFormats = files => {
|
|
52
|
+
const mapFileFormats = (files) => {
|
|
53
53
|
return {
|
|
54
54
|
gherkin: files.filter(file => file.match(/\.feature$/)),
|
|
55
55
|
js: files.filter(file => file.match(/\.t|js$/)),
|
|
56
|
-
}
|
|
57
|
-
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Creates a list of chunks incl. configuration by either dividing a list of scenario
|
|
@@ -62,33 +62,30 @@ const mapFileFormats = files => {
|
|
|
62
62
|
* the splitting.
|
|
63
63
|
*/
|
|
64
64
|
const createChunks = (config, patterns = []) => {
|
|
65
|
-
const files = patterns
|
|
66
|
-
.filter(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
.reduce((acc, val) => acc.concat(val), [])
|
|
65
|
+
const files = patterns.filter(pattern => !!pattern).map((pattern) => {
|
|
66
|
+
return findFiles(pattern).filter((file) => {
|
|
67
|
+
return config.grep ? grepFile(file, config.grep) : true;
|
|
68
|
+
});
|
|
69
|
+
}).reduce((acc, val) => acc.concat(val), []);
|
|
73
70
|
|
|
74
|
-
let chunks = []
|
|
71
|
+
let chunks = [];
|
|
75
72
|
if (typeof config.chunks === 'function') {
|
|
76
|
-
chunks = config.chunks.call(this, files)
|
|
73
|
+
chunks = config.chunks.call(this, files);
|
|
77
74
|
} else if (typeof config.chunks === 'number' || typeof config.chunks === 'string') {
|
|
78
|
-
chunks = splitFiles(files, Math.ceil(files.length / config.chunks))
|
|
75
|
+
chunks = splitFiles(files, Math.ceil(files.length / config.chunks));
|
|
79
76
|
} else {
|
|
80
|
-
throw new Error('chunks is neither a finite number or a valid function')
|
|
77
|
+
throw new Error('chunks is neither a finite number or a valid function');
|
|
81
78
|
}
|
|
82
79
|
|
|
83
|
-
const chunkConfig = { ...config }
|
|
84
|
-
delete chunkConfig.chunks
|
|
80
|
+
const chunkConfig = { ...config };
|
|
81
|
+
delete chunkConfig.chunks;
|
|
85
82
|
|
|
86
|
-
return chunks.map(chunkFiles => {
|
|
87
|
-
const { js, gherkin } = mapFileFormats(chunkFiles)
|
|
88
|
-
return { ...chunkConfig, tests: flattenFiles(js), gherkin: { features: flattenFiles(gherkin) } }
|
|
89
|
-
})
|
|
90
|
-
}
|
|
83
|
+
return chunks.map((chunkFiles) => {
|
|
84
|
+
const { js, gherkin } = mapFileFormats(chunkFiles);
|
|
85
|
+
return { ...chunkConfig, tests: flattenFiles(js), gherkin: { features: flattenFiles(gherkin) } };
|
|
86
|
+
});
|
|
87
|
+
};
|
|
91
88
|
|
|
92
89
|
module.exports = {
|
|
93
90
|
createChunks,
|
|
94
|
-
}
|
|
91
|
+
};
|
package/lib/container.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const glob = require('glob')
|
|
2
2
|
const path = require('path')
|
|
3
3
|
const debug = require('debug')('codeceptjs:container')
|
|
4
4
|
const { MetaStep } = require('./step')
|
|
@@ -34,13 +34,6 @@ let container = {
|
|
|
34
34
|
* Dependency Injection Container
|
|
35
35
|
*/
|
|
36
36
|
class Container {
|
|
37
|
-
/**
|
|
38
|
-
* Get the standard acting helpers of CodeceptJS Container
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
static get STANDARD_ACTING_HELPERS() {
|
|
42
|
-
return ['Playwright', 'WebDriver', 'Puppeteer', 'Appium', 'TestCafe']
|
|
43
|
-
}
|
|
44
37
|
/**
|
|
45
38
|
* Create container with all required helpers and support objects
|
|
46
39
|
*
|
|
@@ -169,18 +162,18 @@ class Container {
|
|
|
169
162
|
* @param {Object<string, *>} newSupport
|
|
170
163
|
* @param {Object<string, *>} newPlugins
|
|
171
164
|
*/
|
|
172
|
-
static clear(newHelpers
|
|
173
|
-
container.helpers = newHelpers
|
|
165
|
+
static clear(newHelpers, newSupport, newPlugins) {
|
|
166
|
+
container.helpers = newHelpers || {}
|
|
174
167
|
container.translation = loadTranslation()
|
|
175
|
-
container.proxySupport = createSupportObjects(newSupport)
|
|
176
|
-
container.plugins = newPlugins
|
|
168
|
+
container.proxySupport = createSupportObjects(newSupport || {})
|
|
169
|
+
container.plugins = newPlugins || {}
|
|
177
170
|
asyncHelperPromise = Promise.resolve()
|
|
178
171
|
store.actor = null
|
|
179
172
|
debug('container cleared')
|
|
180
173
|
}
|
|
181
174
|
|
|
182
175
|
/**
|
|
183
|
-
* @param {Function
|
|
176
|
+
* @param {Function} fn
|
|
184
177
|
* @returns {Promise<void>}
|
|
185
178
|
*/
|
|
186
179
|
static async started(fn = null) {
|
|
@@ -471,7 +464,7 @@ function loadGherkinSteps(paths) {
|
|
|
471
464
|
} else {
|
|
472
465
|
const folderPath = paths.startsWith('.') ? path.join(global.codecept_dir, paths) : ''
|
|
473
466
|
if (folderPath !== '') {
|
|
474
|
-
|
|
467
|
+
glob.sync(folderPath).forEach(file => {
|
|
475
468
|
loadSupportObject(file, `Step Definition from ${file}`)
|
|
476
469
|
})
|
|
477
470
|
}
|
package/lib/helper/AI.js
CHANGED
|
@@ -3,14 +3,13 @@ const ora = require('ora-classic')
|
|
|
3
3
|
const fs = require('fs')
|
|
4
4
|
const path = require('path')
|
|
5
5
|
const ai = require('../ai')
|
|
6
|
+
const standardActingHelpers = require('../plugin/standardActingHelpers')
|
|
6
7
|
const Container = require('../container')
|
|
7
8
|
const { splitByChunks, minifyHtml } = require('../html')
|
|
8
9
|
const { beautify } = require('../utils')
|
|
9
10
|
const output = require('../output')
|
|
10
11
|
const { registerVariable } = require('../pause')
|
|
11
12
|
|
|
12
|
-
const standardActingHelpers = Container.STANDARD_ACTING_HELPERS
|
|
13
|
-
|
|
14
13
|
const gtpRole = {
|
|
15
14
|
user: 'user',
|
|
16
15
|
}
|
|
@@ -145,13 +145,11 @@ module.exports.injected = function (fn, suite, hookName) {
|
|
|
145
145
|
const opts = suite.opts || {}
|
|
146
146
|
const retries = opts[`retry${ucfirst(hookName)}`] || 0
|
|
147
147
|
|
|
148
|
-
const currentTest = hookName === 'before' || hookName === 'after' ? suite?.ctx?.currentTest : null
|
|
149
|
-
|
|
150
148
|
promiseRetry(
|
|
151
149
|
async (retry, number) => {
|
|
152
150
|
try {
|
|
153
151
|
recorder.startUnlessRunning()
|
|
154
|
-
await fn.call(this,
|
|
152
|
+
await fn.call(this, getInjectedArguments(fn))
|
|
155
153
|
await recorder.promise().catch(err => retry(err))
|
|
156
154
|
} catch (err) {
|
|
157
155
|
retry(err)
|
package/lib/mocha/gherkin.js
CHANGED
|
@@ -107,7 +107,7 @@ module.exports = (text, file) => {
|
|
|
107
107
|
)
|
|
108
108
|
continue
|
|
109
109
|
}
|
|
110
|
-
if (child.scenario && (currentLanguage ?
|
|
110
|
+
if (child.scenario && (currentLanguage ? child.scenario.keyword === currentLanguage.contexts.ScenarioOutline : child.scenario.keyword === 'Scenario Outline')) {
|
|
111
111
|
for (const examples of child.scenario.examples) {
|
|
112
112
|
const fields = examples.tableHeader.cells.map(c => c.value)
|
|
113
113
|
for (const example of examples.tableBody) {
|
package/lib/mocha/inject.js
CHANGED
|
@@ -5,7 +5,6 @@ const getInjectedArguments = (fn, test) => {
|
|
|
5
5
|
const testArgs = {}
|
|
6
6
|
const params = parser.getParams(fn) || []
|
|
7
7
|
const objects = container.support()
|
|
8
|
-
|
|
9
8
|
for (const key of params) {
|
|
10
9
|
testArgs[key] = {}
|
|
11
10
|
if (test && test.inject && test.inject[key]) {
|
|
@@ -19,10 +18,6 @@ const getInjectedArguments = (fn, test) => {
|
|
|
19
18
|
testArgs[key] = container.support(key)
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
if (test) {
|
|
23
|
-
testArgs.suite = test?.parent
|
|
24
|
-
testArgs.test = test
|
|
25
|
-
}
|
|
26
21
|
return testArgs
|
|
27
22
|
}
|
|
28
23
|
|
package/lib/plugin/autoDelay.js
CHANGED
|
@@ -2,8 +2,8 @@ const Container = require('../container')
|
|
|
2
2
|
const store = require('../store')
|
|
3
3
|
const recorder = require('../recorder')
|
|
4
4
|
const event = require('../event')
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const log = require('../output').log
|
|
6
|
+
const supportedHelpers = require('./standardActingHelpers').slice()
|
|
7
7
|
|
|
8
8
|
const methodsToDelay = ['click', 'fillField', 'checkOption', 'pressKey', 'doubleClick', 'rightClick']
|
|
9
9
|
|