codeceptjs 3.7.0-beta.14 → 3.7.0-beta.16

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/bin/codecept.js CHANGED
@@ -62,7 +62,7 @@ program
62
62
  .command('check')
63
63
  .option(commandFlags.config.flag, commandFlags.config.description)
64
64
  .description('Checks configuration and environment before running tests')
65
- .option('-t, --timeout [ms]', 'timeout for checks in ms, 20000 by default')
65
+ .option('-t, --timeout [ms]', 'timeout for checks in ms, 50000 by default')
66
66
  .action(errorHandler(require('../lib/command/check')))
67
67
 
68
68
  program
@@ -87,9 +87,9 @@ module.exports = async function (options) {
87
87
 
88
88
  if (config?.ai?.request) {
89
89
  checks.ai = true
90
- printCheck('ai', checks['ai'], 'AI configuration is enabled, request function is set')
90
+ printCheck('ai', checks['ai'], 'Configuration is enabled, request function is set')
91
91
  } else {
92
- printCheck('ai', checks['ai'], 'AI is disabled')
92
+ printCheck('ai', checks['ai'], 'Disabled')
93
93
  }
94
94
 
95
95
  printCheck('tests', checks['tests'], `Total: ${numTests} tests`)
package/lib/effects.js CHANGED
@@ -2,6 +2,7 @@ const recorder = require('./recorder')
2
2
  const { debug } = require('./output')
3
3
  const store = require('./store')
4
4
  const event = require('./event')
5
+ const within = require('./within')
5
6
 
6
7
  /**
7
8
  * A utility function for CodeceptJS tests that acts as a soft assertion.
@@ -178,11 +179,14 @@ async function tryTo(callback) {
178
179
  const sessionName = 'tryTo'
179
180
 
180
181
  let result = false
182
+ let hasAutoRetriesEnabled = store.autoRetries
181
183
  return recorder.add(
182
184
  sessionName,
183
185
  () => {
184
186
  recorder.session.start(sessionName)
185
- store.tryTo = true
187
+ hasAutoRetriesEnabled = store.autoRetries
188
+ if (hasAutoRetriesEnabled) debug('Auto retries disabled inside tryTo effect')
189
+ store.autoRetries = false
186
190
  callback()
187
191
  recorder.add(() => {
188
192
  result = true
@@ -199,7 +203,7 @@ async function tryTo(callback) {
199
203
  return recorder.add(
200
204
  'result',
201
205
  () => {
202
- store.tryTo = undefined
206
+ store.autoRetries = hasAutoRetriesEnabled
203
207
  return result
204
208
  },
205
209
  true,
@@ -215,4 +219,5 @@ module.exports = {
215
219
  hopeThat,
216
220
  retryTo,
217
221
  tryTo,
222
+ within,
218
223
  }
@@ -484,7 +484,7 @@ class Playwright extends Helper {
484
484
  this.currentRunningTest = test
485
485
 
486
486
  recorder.retry({
487
- retries: process.env.FAILED_STEP_RETRIES || 3,
487
+ retries: test.opts?.conditionalRetries || 3,
488
488
  when: err => {
489
489
  if (!err || typeof err.message !== 'string') {
490
490
  return false
@@ -312,7 +312,7 @@ class Puppeteer extends Helper {
312
312
  this.sessionPages = {}
313
313
  this.currentRunningTest = test
314
314
  recorder.retry({
315
- retries: process.env.FAILED_STEP_RETRIES || 3,
315
+ retries: test.opts?.conditionalRetries || 3,
316
316
  when: err => {
317
317
  if (!err || typeof err.message !== 'string') {
318
318
  return false
@@ -1,8 +1,6 @@
1
1
  const event = require('../event')
2
2
  const recorder = require('../recorder')
3
- const container = require('../container')
4
- const { log } = require('../output')
5
-
3
+ const store = require('../store')
6
4
  const defaultConfig = {
7
5
  retries: 3,
8
6
  defaultIgnoredSteps: ['amOnPage', 'wait*', 'send*', 'execute*', 'run*', 'have*'],
@@ -70,9 +68,9 @@ const defaultConfig = {
70
68
  * Use scenario configuration to disable plugin for a test
71
69
  *
72
70
  * ```js
73
- * Scenario('scenario tite', () => {
71
+ * Scenario('scenario tite', { disableRetryFailedStep: true }, () => {
74
72
  * // test goes here
75
- * }).config(test => test.disableRetryFailedStep = true)
73
+ * })
76
74
  * ```
77
75
  *
78
76
  */
@@ -85,19 +83,14 @@ module.exports = config => {
85
83
 
86
84
  const when = err => {
87
85
  if (!enableRetry) return
88
- const store = require('../store')
89
86
  if (store.debugMode) return false
87
+ if (!store.autoRetries) return false
90
88
  if (customWhen) return customWhen(err)
91
89
  return true
92
90
  }
93
91
  config.when = when
94
92
 
95
93
  event.dispatcher.on(event.step.started, step => {
96
- if (process.env.TRY_TO === 'true') {
97
- log('Info: RetryFailedStep plugin is disabled inside tryTo block')
98
- return
99
- }
100
-
101
94
  // if a step is ignored - return
102
95
  for (const ignored of config.ignoredSteps) {
103
96
  if (step.name === ignored) return
@@ -113,9 +106,15 @@ module.exports = config => {
113
106
  })
114
107
 
115
108
  event.dispatcher.on(event.test.before, test => {
116
- if (test && test.disableRetryFailedStep) return // disable retry when a test is not active
117
- // this env var is used to set the retries inside _before() block of helpers
118
- process.env.FAILED_STEP_RETRIES = config.retries
109
+ // pass disableRetryFailedStep is a preferred way to disable retries
110
+ // test.disableRetryFailedStep is used for backward compatibility
111
+ if (test.opts.disableRetryFailedStep || test.disableRetryFailedStep) {
112
+ store.autoRetries = false
113
+ return // disable retry when a test is not active
114
+ }
115
+ // this option is used to set the retries inside _before() block of helpers
116
+ store.autoRetries = true
117
+ test.opts.conditionalRetries = config.retries
119
118
  recorder.retry(config)
120
119
  })
121
120
  }
package/lib/recorder.js CHANGED
@@ -192,6 +192,7 @@ module.exports = {
192
192
  .pop()
193
193
  // no retries or unnamed tasks
194
194
  debug(`${currentQueue()} Running | ${taskName} | Timeout: ${timeout || 'None'}`)
195
+ if (retryOpts) debug(`${currentQueue()} Retry opts`, JSON.stringify(retryOpts))
195
196
 
196
197
  if (!retryOpts || !taskName || !retry) {
197
198
  const [promise, timer] = getTimeoutPromise(timeout, taskName)
package/lib/step/base.js CHANGED
@@ -25,8 +25,7 @@ class Step {
25
25
  this.opts = {}
26
26
  /** @member {string} */
27
27
  this.actor = 'I' // I = actor
28
- /** @member {string} */
29
- this.helperMethod = name // helper method
28
+
30
29
  /** @member {string} */
31
30
  this.status = 'pending'
32
31
  /** @member {string} */
@@ -38,6 +37,13 @@ class Step {
38
37
  /** @member {string} */
39
38
  this.stack = ''
40
39
 
40
+ // These are part of HelperStep class
41
+ // but left here for types compatibility
42
+ /** @member {any} */
43
+ this.helper = null
44
+ /** @member {string} */
45
+ this.helperMethod = name
46
+
41
47
  this.startTime = 0
42
48
  this.endTime = 0
43
49
 
package/lib/store.js CHANGED
@@ -3,17 +3,41 @@
3
3
  * @namespace
4
4
  */
5
5
  const store = {
6
- /** @type {boolean} */
6
+ /**
7
+ * If we are in --debug mode
8
+ * @type {boolean}
9
+ */
7
10
  debugMode: false,
8
- /** @type {boolean} */
11
+
12
+ /**
13
+ * Is timeouts enabled
14
+ * @type {boolean}
15
+ */
9
16
  timeouts: true,
10
- /** @type {boolean} */
17
+
18
+ /**
19
+ * If auto-retries are enabled by retryFailedStep plugin
20
+ * tryTo effect disables them
21
+ * @type {boolean}
22
+ */
23
+ autoRetries: false,
24
+
25
+ /**
26
+ * Tests are executed via dry-run
27
+ * @type {boolean}
28
+ */
11
29
  dryRun: false,
12
- /** @type {boolean} */
30
+ /**
31
+ * If we are in pause mode
32
+ * @type {boolean}
33
+ */
13
34
  onPause: false,
35
+
36
+ // current object states
37
+
14
38
  /** @type {CodeceptJS.Test | null} */
15
39
  currentTest: null,
16
- /** @type {any} */
40
+ /** @type {CodeceptJS.Step | null} */
17
41
  currentStep: null,
18
42
  /** @type {CodeceptJS.Suite | null} */
19
43
  currentSuite: null,
package/lib/within.js CHANGED
@@ -7,6 +7,8 @@ const MetaStep = require('./step/meta')
7
7
  const { isAsyncFunction } = require('./utils')
8
8
 
9
9
  /**
10
+ * TODO: move to effects
11
+ *
10
12
  * @param {CodeceptJS.LocatorOrString} context
11
13
  * @param {Function} fn
12
14
  * @return {Promise<*> | undefined}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.7.0-beta.14",
3
+ "version": "3.7.0-beta.16",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",
@@ -31,6 +31,7 @@
31
31
  "main": "lib/index.js",
32
32
  "exports": {
33
33
  ".": "./lib/index.js",
34
+ "./lib/*": "./lib/*.js",
34
35
  "./els": "./lib/els.js",
35
36
  "./effects": "./lib/effects.js",
36
37
  "./steps": "./lib/steps.js"
@@ -77,8 +78,8 @@
77
78
  "@codeceptjs/configure": "1.0.2",
78
79
  "@codeceptjs/helper": "2.0.4",
79
80
  "@cucumber/cucumber-expressions": "18",
80
- "@cucumber/gherkin": "30",
81
- "@cucumber/messages": "27.1.0",
81
+ "@cucumber/gherkin": "31",
82
+ "@cucumber/messages": "27.2.0",
82
83
  "@xmldom/xmldom": "0.9.7",
83
84
  "acorn": "8.14.0",
84
85
  "arrify": "3.0.0",
@@ -129,16 +130,16 @@
129
130
  "@pollyjs/core": "5.1.0",
130
131
  "@types/chai": "4.3.19",
131
132
  "@types/inquirer": "9.0.7",
132
- "@types/node": "22.12.0",
133
- "@wdio/sauce-service": "9.7.1",
133
+ "@types/node": "22.13.0",
134
+ "@wdio/sauce-service": "9.7.2",
134
135
  "@wdio/selenium-standalone-service": "8.15.0",
135
- "@wdio/utils": "9.6.4",
136
+ "@wdio/utils": "9.7.2",
136
137
  "@xmldom/xmldom": "0.9.7",
137
138
  "chai": "^4.0.0",
138
139
  "chai-as-promised": "7.1.2",
139
140
  "chai-subset": "1.6.0",
140
141
  "documentation": "14.0.3",
141
- "electron": "34.0.1",
142
+ "electron": "34.0.2",
142
143
  "eslint": "^9.19.0",
143
144
  "eslint-plugin-import": "2.31.0",
144
145
  "eslint-plugin-mocha": "10.5.0",
@@ -152,13 +153,13 @@
152
153
  "jsdoc": "^3.6.11",
153
154
  "jsdoc-typeof-plugin": "1.0.0",
154
155
  "json-server": "0.17.4",
155
- "playwright": "1.50.0",
156
+ "playwright": "1.50.1",
156
157
  "prettier": "^3.3.2",
157
158
  "puppeteer": "24.1.1",
158
159
  "qrcode-terminal": "0.12.0",
159
160
  "rosie": "2.1.1",
160
161
  "runok": "0.9.3",
161
- "semver": "7.6.3",
162
+ "semver": "7.7.0",
162
163
  "sinon": "19.0.2",
163
164
  "sinon-chai": "3.7.0",
164
165
  "testcafe": "3.7.1",
@@ -169,8 +170,8 @@
169
170
  "typedoc": "0.27.6",
170
171
  "typedoc-plugin-markdown": "4.4.1",
171
172
  "typescript": "5.7.3",
172
- "wdio-docker-service": "1.5.0",
173
- "webdriverio": "^9.7.1",
173
+ "wdio-docker-service": "3.2.1",
174
+ "webdriverio": "9.7.2",
174
175
  "xml2js": "0.6.2",
175
176
  "xpath": "0.0.34"
176
177
  },
@@ -1762,7 +1762,6 @@ declare namespace CodeceptJS {
1762
1762
  // @ts-ignore
1763
1763
  // @ts-ignore
1764
1764
  // @ts-ignore
1765
- // @ts-ignore
1766
1765
  type MockServerConfig = {
1767
1766
  port?: number;
1768
1767
  host?: string;
@@ -1890,7 +1889,6 @@ declare namespace CodeceptJS {
1890
1889
  // @ts-ignore
1891
1890
  // @ts-ignore
1892
1891
  // @ts-ignore
1893
- // @ts-ignore
1894
1892
  class MockServer {
1895
1893
  /**
1896
1894
  * Start the mock server
@@ -2927,7 +2925,6 @@ declare namespace CodeceptJS {
2927
2925
  // @ts-ignore
2928
2926
  // @ts-ignore
2929
2927
  // @ts-ignore
2930
- // @ts-ignore
2931
2928
  type PlaywrightConfig = {
2932
2929
  url?: string;
2933
2930
  browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
@@ -6307,7 +6304,6 @@ declare namespace CodeceptJS {
6307
6304
  // @ts-ignore
6308
6305
  // @ts-ignore
6309
6306
  // @ts-ignore
6310
- // @ts-ignore
6311
6307
  type PuppeteerConfig = {
6312
6308
  url: string;
6313
6309
  basicAuth?: any;
@@ -8117,7 +8113,6 @@ declare namespace CodeceptJS {
8117
8113
  // @ts-ignore
8118
8114
  // @ts-ignore
8119
8115
  // @ts-ignore
8120
- // @ts-ignore
8121
8116
  type RESTConfig = {
8122
8117
  endpoint?: string;
8123
8118
  prettyPrintJson?: boolean;
@@ -9265,7 +9260,6 @@ declare namespace CodeceptJS {
9265
9260
  // @ts-ignore
9266
9261
  // @ts-ignore
9267
9262
  // @ts-ignore
9268
- // @ts-ignore
9269
9263
  type WebDriverConfig = {
9270
9264
  url: string;
9271
9265
  browser: string;
@@ -1789,7 +1789,6 @@ declare namespace CodeceptJS {
1789
1789
  // @ts-ignore
1790
1790
  // @ts-ignore
1791
1791
  // @ts-ignore
1792
- // @ts-ignore
1793
1792
  type MockServerConfig = {
1794
1793
  port?: number;
1795
1794
  host?: string;
@@ -1917,7 +1916,6 @@ declare namespace CodeceptJS {
1917
1916
  // @ts-ignore
1918
1917
  // @ts-ignore
1919
1918
  // @ts-ignore
1920
- // @ts-ignore
1921
1919
  class MockServer {
1922
1920
  /**
1923
1921
  * Start the mock server
@@ -3020,7 +3018,6 @@ declare namespace CodeceptJS {
3020
3018
  // @ts-ignore
3021
3019
  // @ts-ignore
3022
3020
  // @ts-ignore
3023
- // @ts-ignore
3024
3021
  type PlaywrightConfig = {
3025
3022
  url?: string;
3026
3023
  browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
@@ -6551,7 +6548,6 @@ declare namespace CodeceptJS {
6551
6548
  // @ts-ignore
6552
6549
  // @ts-ignore
6553
6550
  // @ts-ignore
6554
- // @ts-ignore
6555
6551
  type PuppeteerConfig = {
6556
6552
  url: string;
6557
6553
  basicAuth?: any;
@@ -8497,7 +8493,6 @@ declare namespace CodeceptJS {
8497
8493
  // @ts-ignore
8498
8494
  // @ts-ignore
8499
8495
  // @ts-ignore
8500
- // @ts-ignore
8501
8496
  type RESTConfig = {
8502
8497
  endpoint?: string;
8503
8498
  prettyPrintJson?: boolean;
@@ -9705,7 +9700,6 @@ declare namespace CodeceptJS {
9705
9700
  // @ts-ignore
9706
9701
  // @ts-ignore
9707
9702
  // @ts-ignore
9708
- // @ts-ignore
9709
9703
  type WebDriverConfig = {
9710
9704
  url: string;
9711
9705
  browser: string;
@@ -11787,6 +11781,10 @@ declare namespace CodeceptJS {
11787
11781
  * Dependency Injection Container
11788
11782
  */
11789
11783
  class Container {
11784
+ /**
11785
+ * Get the standard acting helpers of CodeceptJS Container
11786
+ */
11787
+ static STANDARD_ACTING_HELPERS: any;
11790
11788
  /**
11791
11789
  * Create container with all required helpers and support objects
11792
11790
  */
@@ -11831,16 +11829,12 @@ declare namespace CodeceptJS {
11831
11829
  }, newPlugins: {
11832
11830
  [key: string]: any;
11833
11831
  }): void;
11834
- static started(fn: (...params: any[]) => any): Promise<void>;
11832
+ static started(fn: ((...params: any[]) => any) | null): Promise<void>;
11835
11833
  /**
11836
11834
  * Share data across worker threads
11837
11835
  * @param options - set {local: true} to not share among workers
11838
11836
  */
11839
11837
  static share(data: any, options: any): void;
11840
- /**
11841
- * List of helpers that are used in CodeceptJS and can't be used together
11842
- */
11843
- static STANDARD_ACTING_HELPERS: string[];
11844
11838
  }
11845
11839
  /**
11846
11840
  * Method collect own property and prototype
@@ -12204,12 +12198,13 @@ declare namespace CodeceptJS {
12204
12198
  args: any[];
12205
12199
  opts: Record<string, any>;
12206
12200
  actor: string;
12207
- helperMethod: string;
12208
12201
  status: string;
12209
12202
  prefix: string;
12210
12203
  comment: string;
12211
12204
  metaStep: any;
12212
12205
  stack: string;
12206
+ helper: any;
12207
+ helperMethod: string;
12213
12208
  timeout: any;
12214
12209
  /**
12215
12210
  * @param timeout - timeout in milliseconds or 0 if no timeout
@@ -12232,12 +12227,29 @@ declare namespace CodeceptJS {
12232
12227
  * global values for current session
12233
12228
  */
12234
12229
  namespace store {
12230
+ /**
12231
+ * If we are in --debug mode
12232
+ */
12235
12233
  var debugMode: boolean;
12234
+ /**
12235
+ * Is timeouts enabled
12236
+ */
12236
12237
  var timeouts: boolean;
12238
+ /**
12239
+ * If auto-retries are enabled by retryFailedStep plugin
12240
+ * tryTo effect disables them
12241
+ */
12242
+ var autoRetries: boolean;
12243
+ /**
12244
+ * Tests are executed via dry-run
12245
+ */
12237
12246
  var dryRun: boolean;
12247
+ /**
12248
+ * If we are in pause mode
12249
+ */
12238
12250
  var onPause: boolean;
12239
12251
  var currentTest: CodeceptJS.Test | null;
12240
- var currentStep: any;
12252
+ var currentStep: CodeceptJS.Step | null;
12241
12253
  var currentSuite: CodeceptJS.Suite | null;
12242
12254
  }
12243
12255
  /**
@@ -12378,6 +12390,9 @@ declare namespace CodeceptJS {
12378
12390
  */
12379
12391
  err: Error | null;
12380
12392
  }
12393
+ /**
12394
+ * TODO: move to effects
12395
+ */
12381
12396
  function within(context: CodeceptJS.LocatorOrString, fn: (...params: any[]) => any): Promise<any> | undefined;
12382
12397
  /**
12383
12398
  * This is a wrapper on top of [Detox](https://github.com/wix/Detox) library, aimied to unify testing experience for CodeceptJS framework.