codeceptjs 3.7.0-beta.11 → 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 CHANGED
@@ -200,12 +200,12 @@ class Codecept {
200
200
  }
201
201
  const done = () => {
202
202
  event.emit(event.all.result, container.result())
203
- event.emit(event.all.after, this)
203
+ event.emit(event.all.after)
204
204
  resolve()
205
205
  }
206
206
 
207
207
  try {
208
- event.emit(event.all.before, this)
208
+ event.emit(event.all.before)
209
209
  mocha.run(() => done())
210
210
  } catch (e) {
211
211
  output.error(e.stack)
@@ -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 = [...container.STANDARD_ACTING_HELPERS, 'REST']
8
+ const actingHelpers = [...require('../plugin/standardActingHelpers'), 'REST']
9
9
 
10
10
  /**
11
11
  * Prepare data and generate content of definitions file
@@ -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 = Container.STANDARD_ACTING_HELPERS
7
+ const webHelpers = require('../plugin/standardActingHelpers')
8
8
 
9
9
  module.exports = async function (path, options) {
10
10
  // Backward compatibility for --profile
package/lib/container.js CHANGED
@@ -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
  *
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, { ...getInjectedArguments(fn), suite, test: currentTest })
152
+ await fn.call(this, getInjectedArguments(fn))
155
153
  await recorder.promise().catch(err => retry(err))
156
154
  } catch (err) {
157
155
  retry(err)
@@ -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
 
@@ -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 { log } = require('../output')
6
- const standardActingHelpers = Container.STANDARD_ACTING_HELPERS
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
 
@@ -3,7 +3,7 @@ const fs = require('fs')
3
3
  const Container = require('../container')
4
4
  const recorder = require('../recorder')
5
5
  const event = require('../event')
6
- const supportedHelpers = Container.STANDARD_ACTING_HELPERS
6
+ const supportedHelpers = require('./standardActingHelpers')
7
7
  const { scanForErrorMessages } = require('../html')
8
8
  const { output } = require('..')
9
9
  const { humanizeString, ucfirst } = require('../utils')
@@ -1,23 +1,12 @@
1
1
  const { retryTo } = require('../effects')
2
2
 
3
- module.exports = function (config) {
4
- console.log(`
5
- Deprecation Warning: 'retryTo' has been moved to the effects module.
6
- You should update your tests to use it as follows:
7
-
8
- \`\`\`javascript
9
- const { retryTo } = require('codeceptjs/effects');
10
-
11
- // Example: Retry these steps 5 times before failing
12
- await retryTo((tryNum) => {
13
- I.switchTo('#editor frame');
14
- I.click('Open');
15
- I.see('Opened');
16
- }, 5);
17
- \`\`\`
3
+ const defaultConfig = {
4
+ registerGlobal: true,
5
+ }
18
6
 
19
- For more details, refer to the documentation.
20
- `)
7
+ module.exports = function (config) {
8
+ config = Object.assign(defaultConfig, config)
9
+ console.log(`Deprecation Warning: 'retryTo' has been moved to the 'codeceptjs/effects' module`)
21
10
 
22
11
  if (config.registerGlobal) {
23
12
  global.retryTo = retryTo
@@ -15,7 +15,7 @@ const defaultConfig = {
15
15
  fullPageScreenshots: false,
16
16
  }
17
17
 
18
- const supportedHelpers = Container.STANDARD_ACTING_HELPERS
18
+ const supportedHelpers = require('./standardActingHelpers')
19
19
 
20
20
  /**
21
21
  * Creates screenshot on failure. Screenshot is saved into `output` directory.
@@ -1,6 +1,3 @@
1
- const Container = require('../container')
2
- // due to using this in internal tooling we won't post deprecation warning
3
- // but please switch to Container.STANDARD_ACTING_HELPERS
4
- const standardActingHelpers = Container.STANDARD_ACTING_HELPERS
1
+ const standardActingHelpers = ['Playwright', 'WebDriver', 'Puppeteer', 'Appium', 'TestCafe']
5
2
 
6
3
  module.exports = standardActingHelpers
@@ -12,7 +12,7 @@ const event = require('../event')
12
12
  const output = require('../output')
13
13
  const { template, deleteDir } = require('../utils')
14
14
 
15
- const supportedHelpers = Container.STANDARD_ACTING_HELPERS
15
+ const supportedHelpers = require('./standardActingHelpers')
16
16
 
17
17
  const defaultConfig = {
18
18
  deleteSuccessful: true,
@@ -1,21 +1,12 @@
1
1
  const { tryTo } = require('../effects')
2
2
 
3
- module.exports = function (config) {
4
- console.log(`
5
- Deprecated Warning: 'tryTo' has been moved to the effects module.
6
- You should update your tests to use it as follows:
7
-
8
- \`\`\`javascript
9
- const { tryTo } = require('codeceptjs/effects');
10
-
11
- // Example: failed step won't fail a test but will return true/false
12
- await tryTo(() => {
13
- I.switchTo('#editor frame');
14
- });
15
- \`\`\`
3
+ const defaultConfig = {
4
+ registerGlobal: true,
5
+ }
16
6
 
17
- For more details, refer to the documentation.
18
- `)
7
+ module.exports = function (config) {
8
+ config = Object.assign(defaultConfig, config)
9
+ console.log(`Deprecation Warning: 'tryTo' has been moved to the 'codeceptjs/effects' module`)
19
10
 
20
11
  if (config.registerGlobal) {
21
12
  global.tryTo = tryTo
package/lib/step/base.js CHANGED
@@ -190,8 +190,8 @@ class Step {
190
190
  args.push(arg.name)
191
191
  } else if (typeof arg == 'string') {
192
192
  args.push(arg)
193
- } else {
194
- args.push(JSON.stringify(arg).slice(0, 300))
193
+ } else if (arg) {
194
+ args.push((JSON.stringify(arg) || '').slice(0, 300))
195
195
  }
196
196
  }
197
197
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.7.0-beta.11",
3
+ "version": "3.7.0-beta.13",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",