codeceptjs 3.7.0-beta.13 → 3.7.0-beta.14

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  const { existsSync, readFileSync } = require('fs')
2
- const glob = require('glob')
2
+ const { globSync } = require('glob')
3
3
  const fsPath = require('path')
4
4
  const { resolve } = require('path')
5
5
 
@@ -168,15 +168,17 @@ class Codecept {
168
168
  }
169
169
 
170
170
  for (pattern of patterns) {
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
- })
171
+ if (pattern) {
172
+ globSync(pattern, options).forEach(file => {
173
+ if (file.includes('node_modules')) return
174
+ if (!fsPath.isAbsolute(file)) {
175
+ file = fsPath.join(global.codecept_dir, file)
176
+ }
177
+ if (!this.testFiles.includes(fsPath.resolve(file))) {
178
+ this.testFiles.push(fsPath.resolve(file))
179
+ }
180
+ })
181
+ }
180
182
  }
181
183
  }
182
184
 
@@ -200,12 +202,12 @@ class Codecept {
200
202
  }
201
203
  const done = () => {
202
204
  event.emit(event.all.result, container.result())
203
- event.emit(event.all.after)
205
+ event.emit(event.all.after, this)
204
206
  resolve()
205
207
  }
206
208
 
207
209
  try {
208
- event.emit(event.all.before)
210
+ event.emit(event.all.before, this)
209
211
  mocha.run(() => done())
210
212
  } catch (e) {
211
213
  output.error(e.stack)
@@ -1,7 +1,6 @@
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')
5
4
  const store = require('../store')
6
5
  const container = require('../container')
7
6
  const figures = require('figures')
@@ -23,6 +22,7 @@ module.exports = async function (options) {
23
22
  container: false,
24
23
  pageObjects: false,
25
24
  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,6 +51,8 @@ module.exports = async function (options) {
51
51
  checks.container = err
52
52
  }
53
53
 
54
+ const standardActingHelpers = container.STANDARD_ACTING_HELPERS
55
+
54
56
  printCheck('container', checks['container'])
55
57
 
56
58
  if (codecept) {
@@ -83,6 +85,13 @@ module.exports = async function (options) {
83
85
  }
84
86
  }
85
87
 
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
+
86
95
  printCheck('tests', checks['tests'], `Total: ${numTests} tests`)
87
96
 
88
97
  store.dryRun = true
@@ -170,7 +179,7 @@ function printCheck(name, value, comment = '') {
170
179
  }
171
180
 
172
181
  if (value instanceof Error) {
173
- comment = `${comment} ${chalk.red.italic(value.message)}`.trim()
182
+ comment = `${comment} ${chalk.red(value.message)}`.trim()
174
183
  }
175
184
 
176
185
  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 = [...require('../plugin/standardActingHelpers'), 'REST']
8
+ const actingHelpers = [...container.STANDARD_ACTING_HELPERS, '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 glob = require('glob');
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 { globSync } = 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
- glob.sync(options.feature || config.gherkin.features, { cwd: options.feature ? '.' : global.codecept_dir }).forEach(file => {
45
+ const files = []
46
+ globSync(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 = require('../plugin/standardActingHelpers')
7
+ const webHelpers = Container.STANDARD_ACTING_HELPERS
8
8
 
9
9
  module.exports = async function (path, options) {
10
10
  // Backward compatibility for --profile
@@ -1,60 +1,60 @@
1
- const glob = require('glob');
2
- const path = require('path');
3
- const fs = require('fs');
1
+ const { globSync } = 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
- glob.sync(pattern).forEach((file) => {
28
- files.push(path.resolve(file));
29
- });
27
+ globSync(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,30 +62,33 @@ const mapFileFormats = (files) => {
62
62
  * the splitting.
63
63
  */
64
64
  const createChunks = (config, patterns = []) => {
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), []);
65
+ const files = patterns
66
+ .filter(pattern => !!pattern)
67
+ .map(pattern => {
68
+ return findFiles(pattern).filter(file => {
69
+ return config.grep ? grepFile(file, config.grep) : true
70
+ })
71
+ })
72
+ .reduce((acc, val) => acc.concat(val), [])
70
73
 
71
- let chunks = [];
74
+ let chunks = []
72
75
  if (typeof config.chunks === 'function') {
73
- chunks = config.chunks.call(this, files);
76
+ chunks = config.chunks.call(this, files)
74
77
  } else if (typeof config.chunks === 'number' || typeof config.chunks === 'string') {
75
- chunks = splitFiles(files, Math.ceil(files.length / config.chunks));
78
+ chunks = splitFiles(files, Math.ceil(files.length / config.chunks))
76
79
  } else {
77
- throw new Error('chunks is neither a finite number or a valid function');
80
+ throw new Error('chunks is neither a finite number or a valid function')
78
81
  }
79
82
 
80
- const chunkConfig = { ...config };
81
- delete chunkConfig.chunks;
83
+ const chunkConfig = { ...config }
84
+ delete chunkConfig.chunks
82
85
 
83
- return chunks.map((chunkFiles) => {
84
- const { js, gherkin } = mapFileFormats(chunkFiles);
85
- return { ...chunkConfig, tests: flattenFiles(js), gherkin: { features: flattenFiles(gherkin) } };
86
- });
87
- };
86
+ return chunks.map(chunkFiles => {
87
+ const { js, gherkin } = mapFileFormats(chunkFiles)
88
+ return { ...chunkConfig, tests: flattenFiles(js), gherkin: { features: flattenFiles(gherkin) } }
89
+ })
90
+ }
88
91
 
89
92
  module.exports = {
90
93
  createChunks,
91
- };
94
+ }
package/lib/container.js CHANGED
@@ -1,4 +1,4 @@
1
- const glob = require('glob')
1
+ const { globSync } = require('glob')
2
2
  const path = require('path')
3
3
  const debug = require('debug')('codeceptjs:container')
4
4
  const { MetaStep } = require('./step')
@@ -34,6 +34,13 @@ 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
+ }
37
44
  /**
38
45
  * Create container with all required helpers and support objects
39
46
  *
@@ -162,18 +169,18 @@ class Container {
162
169
  * @param {Object<string, *>} newSupport
163
170
  * @param {Object<string, *>} newPlugins
164
171
  */
165
- static clear(newHelpers, newSupport, newPlugins) {
166
- container.helpers = newHelpers || {}
172
+ static clear(newHelpers = {}, newSupport = {}, newPlugins = {}) {
173
+ container.helpers = newHelpers
167
174
  container.translation = loadTranslation()
168
- container.proxySupport = createSupportObjects(newSupport || {})
169
- container.plugins = newPlugins || {}
175
+ container.proxySupport = createSupportObjects(newSupport)
176
+ container.plugins = newPlugins
170
177
  asyncHelperPromise = Promise.resolve()
171
178
  store.actor = null
172
179
  debug('container cleared')
173
180
  }
174
181
 
175
182
  /**
176
- * @param {Function} fn
183
+ * @param {Function|null} fn
177
184
  * @returns {Promise<void>}
178
185
  */
179
186
  static async started(fn = null) {
@@ -464,7 +471,7 @@ function loadGherkinSteps(paths) {
464
471
  } else {
465
472
  const folderPath = paths.startsWith('.') ? path.join(global.codecept_dir, paths) : ''
466
473
  if (folderPath !== '') {
467
- glob.sync(folderPath).forEach(file => {
474
+ globSync(folderPath).forEach(file => {
468
475
  loadSupportObject(file, `Step Definition from ${file}`)
469
476
  })
470
477
  }
package/lib/helper/AI.js CHANGED
@@ -3,13 +3,14 @@ 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')
7
6
  const Container = require('../container')
8
7
  const { splitByChunks, minifyHtml } = require('../html')
9
8
  const { beautify } = require('../utils')
10
9
  const output = require('../output')
11
10
  const { registerVariable } = require('../pause')
12
11
 
12
+ const standardActingHelpers = Container.STANDARD_ACTING_HELPERS
13
+
13
14
  const gtpRole = {
14
15
  user: 'user',
15
16
  }
@@ -145,11 +145,13 @@ 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
+
148
150
  promiseRetry(
149
151
  async (retry, number) => {
150
152
  try {
151
153
  recorder.startUnlessRunning()
152
- await fn.call(this, getInjectedArguments(fn))
154
+ await fn.call(this, { ...getInjectedArguments(fn), suite, test: currentTest })
153
155
  await recorder.promise().catch(err => retry(err))
154
156
  } catch (err) {
155
157
  retry(err)
@@ -107,7 +107,7 @@ module.exports = (text, file) => {
107
107
  )
108
108
  continue
109
109
  }
110
- if (child.scenario && (currentLanguage ? child.scenario.keyword === currentLanguage.contexts.ScenarioOutline : child.scenario.keyword === 'Scenario Outline')) {
110
+ if (child.scenario && (currentLanguage ? currentLanguage.contexts.ScenarioOutline.includes(child.scenario.keyword) : 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) {
@@ -5,6 +5,7 @@ const getInjectedArguments = (fn, test) => {
5
5
  const testArgs = {}
6
6
  const params = parser.getParams(fn) || []
7
7
  const objects = container.support()
8
+
8
9
  for (const key of params) {
9
10
  testArgs[key] = {}
10
11
  if (test && test.inject && test.inject[key]) {
@@ -18,6 +19,10 @@ const getInjectedArguments = (fn, test) => {
18
19
  testArgs[key] = container.support(key)
19
20
  }
20
21
 
22
+ if (test) {
23
+ testArgs.suite = test?.parent
24
+ testArgs.test = test
25
+ }
21
26
  return testArgs
22
27
  }
23
28
 
package/lib/output.js CHANGED
@@ -115,7 +115,7 @@ module.exports = {
115
115
  }
116
116
  }
117
117
 
118
- let stepLine = step.toCliStyled()
118
+ let stepLine = step.toCliStyled ? step.toCliStyled() : step.toString()
119
119
  if (step.metaStep && outputLevel >= 1) {
120
120
  // this.stepShift += 2;
121
121
  stepLine = colors.dim(truncate(stepLine, this.spaceShift))
@@ -2,6 +2,7 @@ const debug = require('debug')('codeceptjs:analyze')
2
2
  const { isMainThread } = require('node:worker_threads')
3
3
  const { arrowRight } = require('figures')
4
4
  const container = require('../container')
5
+ const store = require('../store')
5
6
  const ai = require('../ai')
6
7
  const colors = require('chalk')
7
8
  const ora = require('ora-classic')
@@ -75,6 +76,7 @@ const defaultConfig = {
75
76
 
76
77
  * SUMMARY <summary_of_errors>
77
78
  * CATEGORY <category_of_failure>
79
+ * URL <url_of_failure_if_any>
78
80
  * ERROR <error_message_1>, <error_message_2>, ...
79
81
  * STEP <step_of_failure> (use CodeceptJS format I.click(), I.see(), etc; if all failures happend on the same step)
80
82
  * SUITE <suite_title>, <suite_title> (if SUITE is present, and if all tests in the group have the same suite or suites)
@@ -86,11 +88,6 @@ const defaultConfig = {
86
88
  x ...
87
89
  `,
88
90
  },
89
- {
90
- role: 'assistant',
91
- content: `## '
92
- `,
93
- },
94
91
  ]
95
92
  return messages
96
93
  },
@@ -137,6 +134,7 @@ const defaultConfig = {
137
134
  * ERROR <error_message_1>, <error_message_2>, ...
138
135
  * CATEGORY <category_of_failure>
139
136
  * STEPS <step_of_failure>
137
+ * URL <url_of_failure_if_any>
140
138
 
141
139
  Do not add any other sections or explanations. Only CATEGORY, SUMMARY, STEPS.
142
140
  ${config.vision ? 'Also a screenshot of the page is attached to the prompt.' : ''}
@@ -338,12 +336,13 @@ function serializeTest(test) {
338
336
  }
339
337
 
340
338
  function formatResponse(response) {
341
- if (!response.startsWith('##')) response = '## ' + response
342
339
  return response
340
+ .replace(/<think>([\s\S]*?)<\/think>/g, store.debugMode ? colors.cyan('$1') : '')
343
341
  .split('\n')
344
342
  .map(line => line.trim())
345
343
  .filter(line => !/^[A-Z\s]+$/.test(line))
346
344
  .map(line => markdownToAnsi(line))
347
345
  .map(line => line.replace(/^x /gm, ` ${colors.red.bold('x')} `))
348
346
  .join('\n')
347
+ .trim()
349
348
  }