codeceptjs 3.7.4 → 3.7.5-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.7.4",
3
+ "version": "3.7.5-beta.1",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "repository": "Codeception/codeceptjs",
44
44
  "scripts": {
45
- "json-server": "json-server test/data/rest/db.json --host 0.0.0.0 -p 8010 --watch -m test/data/rest/headers.js",
45
+ "test-server": "node bin/test-server.js test/data/rest/db.json --host 0.0.0.0 -p 8010",
46
46
  "json-server:graphql": "node test/data/graphql/index.js",
47
47
  "lint": "eslint bin/ examples/ lib/ test/ translations/ runok.js",
48
48
  "lint-fix": "eslint bin/ examples/ lib/ test/ translations/ runok.js --fix",
@@ -86,6 +86,7 @@
86
86
  "axios": "1.11.0",
87
87
  "chalk": "4.1.2",
88
88
  "cheerio": "^1.0.0",
89
+ "chokidar": "^4.0.3",
89
90
  "commander": "11.1.0",
90
91
  "cross-spawn": "7.0.6",
91
92
  "css-to-xpath": "0.1.0",
@@ -98,17 +99,18 @@
98
99
  "fuse.js": "^7.0.0",
99
100
  "glob": ">=9.0.0 <12",
100
101
  "html-minifier-terser": "7.2.0",
101
- "inquirer": "8.2.6",
102
+ "inquirer": "^8.2.7",
102
103
  "invisi-data": "^1.0.0",
103
104
  "joi": "17.13.3",
104
105
  "js-beautify": "1.15.4",
105
106
  "lodash.clonedeep": "4.5.0",
106
- "lodash.shuffle": "4.2.0",
107
107
  "lodash.merge": "4.6.2",
108
+ "lodash.shuffle": "4.2.0",
108
109
  "mkdirp": "3.0.1",
109
110
  "mocha": "11.6.0",
110
111
  "monocart-coverage-reports": "2.12.6",
111
112
  "ms": "2.1.3",
113
+ "multer": "^2.0.2",
112
114
  "ora-classic": "5.4.2",
113
115
  "parse-function": "5.6.10",
114
116
  "parse5": "7.3.0",
@@ -125,7 +127,7 @@
125
127
  "@codeceptjs/expect-helper": "^1.0.2",
126
128
  "@codeceptjs/mock-request": "0.3.1",
127
129
  "@eslint/eslintrc": "3.3.1",
128
- "@eslint/js": "9.31.0",
130
+ "@eslint/js": "9.34.0",
129
131
  "@faker-js/faker": "9.8.0",
130
132
  "@pollyjs/adapter-puppeteer": "6.0.6",
131
133
  "@pollyjs/core": "6.0.6",
@@ -145,7 +147,7 @@
145
147
  "eslint-plugin-import": "2.32.0",
146
148
  "eslint-plugin-mocha": "11.1.0",
147
149
  "expect": "30.0.5",
148
- "express": "5.1.0",
150
+ "express": "^5.1.0",
149
151
  "globals": "16.2.0",
150
152
  "graphql": "16.11.0",
151
153
  "graphql-tag": "^2.12.6",
@@ -440,7 +440,7 @@ declare namespace CodeceptJS {
440
440
  interface IHook {}
441
441
  interface IScenario {}
442
442
  interface IFeature {
443
- (title: string): FeatureConfig
443
+ (title: string, opts?: { [key: string]: any }): FeatureConfig
444
444
  }
445
445
  interface CallbackOrder extends Array<any> {}
446
446
  interface SupportObject {
@@ -486,6 +486,7 @@ declare namespace CodeceptJS {
486
486
  todo: IScenario
487
487
  }
488
488
  interface Feature extends IFeature {
489
+ only: IFeature
489
490
  skip: IFeature
490
491
  }
491
492
  interface IData {
@@ -519,11 +520,17 @@ declare namespace CodeceptJS {
519
520
  }
520
521
  }
521
522
 
523
+ type TryTo = <T>(fn: () => Promise<T> | T) => Promise<T | false>;
524
+ type HopeThat = <T>(fn: () => Promise<T> | T) => Promise<T | false>;
525
+ type RetryTo = <T>(fn: () => Promise<T> | T, retries?: number) => Promise<T>;
526
+
527
+
522
528
  // Globals
523
529
  declare const codecept_dir: string
524
530
  declare const output_dir: string
525
- declare function tryTo(...fn): Promise<boolean>
526
- declare function retryTo(...fn): Promise<null>
531
+ declare const tryTo: TryTo;
532
+ declare const retryTo: RetryTo;
533
+ declare const hopeThat: HopeThat;
527
534
 
528
535
  declare const actor: CodeceptJS.actor
529
536
  declare const codecept_actor: CodeceptJS.actor
@@ -545,7 +552,7 @@ declare const Given: typeof CodeceptJS.addStep
545
552
  declare const When: typeof CodeceptJS.addStep
546
553
  declare const Then: typeof CodeceptJS.addStep
547
554
 
548
- declare const Feature: typeof CodeceptJS.Feature
555
+ declare const Feature: CodeceptJS.Feature
549
556
  declare const Scenario: CodeceptJS.Scenario
550
557
  declare const xScenario: CodeceptJS.IScenario
551
558
  declare const xFeature: CodeceptJS.IFeature
@@ -634,3 +641,9 @@ declare module 'codeceptjs' {
634
641
  declare module '@codeceptjs/helper' {
635
642
  export = CodeceptJS.Helper
636
643
  }
644
+
645
+ declare module 'codeceptjs/effects' {
646
+ export const tryTo: TryTo;
647
+ export const retryTo: RetryTo;
648
+ export const hopeThat: HopeThat;
649
+ }
@@ -2734,6 +2734,7 @@ declare namespace CodeceptJS {
2734
2734
  * @property [recordHar] - record HAR and will be saved to `output/har`. See more of [HAR options](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har).
2735
2735
  * @property [testIdAttribute = data-testid] - locate elements based on the testIdAttribute. See more of [locate by test id](https://playwright.dev/docs/locators#locate-by-test-id).
2736
2736
  */
2737
+ // @ts-ignore
2737
2738
  type PlaywrightConfig = {
2738
2739
  url?: string;
2739
2740
  browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
@@ -6110,6 +6111,7 @@ declare namespace CodeceptJS {
6110
6111
  * @property [chrome] - pass additional [Puppeteer run options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
6111
6112
  * @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
6112
6113
  */
6114
+ // @ts-ignore
6113
6115
  type PuppeteerConfig = {
6114
6116
  url: string;
6115
6117
  basicAuth?: any;
@@ -6533,6 +6535,17 @@ declare namespace CodeceptJS {
6533
6535
  * {{ react }}
6534
6536
  */
6535
6537
  _locate(): Promise<any>;
6538
+ /**
6539
+ * Get single element by different locator types, including strict locator
6540
+ * Should be used in custom helpers:
6541
+ *
6542
+ * ```js
6543
+ * const element = await this.helpers['Puppeteer']._locateElement({name: 'password'});
6544
+ * ```
6545
+ *
6546
+ * {{ react }}
6547
+ */
6548
+ _locateElement(): Promise<any>;
6536
6549
  /**
6537
6550
  * Find a checkbox by providing human-readable text:
6538
6551
  * NOTE: Assumes the checkable element exists
@@ -6569,6 +6582,17 @@ declare namespace CodeceptJS {
6569
6582
  * @returns WebElement of being used Web helper
6570
6583
  */
6571
6584
  grabWebElements(locator: CodeceptJS.LocatorOrString): Promise<any>;
6585
+ /**
6586
+ * Grab WebElement for given locator
6587
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
6588
+ *
6589
+ * ```js
6590
+ * const webElement = await I.grabWebElement('#button');
6591
+ * ```
6592
+ * @param locator - element located by CSS|XPath|strict locator.
6593
+ * @returns WebElement of being used Web helper
6594
+ */
6595
+ grabWebElement(locator: CodeceptJS.LocatorOrString): Promise<any>;
6572
6596
  /**
6573
6597
  * Switch focus to a particular tab by its number. It waits tabs loading and then switch tab
6574
6598
  *
@@ -7904,6 +7928,22 @@ declare namespace CodeceptJS {
7904
7928
  */
7905
7929
  flushWebSocketMessages(): Promise<any>;
7906
7930
  }
7931
+ /**
7932
+ * Find elements using Puppeteer's native element discovery methods
7933
+ * Note: Unlike Playwright, Puppeteer's Locator API doesn't have .all() method for multiple elements
7934
+ * @param matcher - Puppeteer context to search within
7935
+ * @param locator - Locator specification
7936
+ * @returns Array of ElementHandle objects
7937
+ */
7938
+ function findElements(matcher: any, locator: any | string): Promise<any[]>;
7939
+ /**
7940
+ * Find a single element using Puppeteer's native element discovery methods
7941
+ * Note: Puppeteer Locator API doesn't have .first() method like Playwright
7942
+ * @param matcher - Puppeteer context to search within
7943
+ * @param locator - Locator specification
7944
+ * @returns Single ElementHandle object
7945
+ */
7946
+ function findElement(matcher: any, locator: any | string): Promise<object>;
7907
7947
  /**
7908
7948
  * ## Configuration
7909
7949
  * @property [endpoint] - API base URL
@@ -7916,6 +7956,7 @@ declare namespace CodeceptJS {
7916
7956
  * @property [onResponse] - an async function which can update response object.
7917
7957
  * @property [maxUploadFileSize] - set the max content file size in MB when performing api calls.
7918
7958
  */
7959
+ // @ts-ignore
7919
7960
  type RESTConfig = {
7920
7961
  endpoint?: string;
7921
7962
  prettyPrintJson?: boolean;
@@ -9061,6 +9102,7 @@ declare namespace CodeceptJS {
9061
9102
  * @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
9062
9103
  * @property [logLevel = silent] - level of logging verbosity. Default: silent. Options: trace | debug | info | warn | error | silent. More info: https://webdriver.io/docs/configuration/#loglevel
9063
9104
  */
9105
+ // @ts-ignore
9064
9106
  type WebDriverConfig = {
9065
9107
  url: string;
9066
9108
  browser: string;
@@ -9531,6 +9573,17 @@ declare namespace CodeceptJS {
9531
9573
  * @returns WebElement of being used Web helper
9532
9574
  */
9533
9575
  grabWebElements(locator: CodeceptJS.LocatorOrString): Promise<any>;
9576
+ /**
9577
+ * Grab WebElement for given locator
9578
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
9579
+ *
9580
+ * ```js
9581
+ * const webElement = await I.grabWebElement('#button');
9582
+ * ```
9583
+ * @param locator - element located by CSS|XPath|strict locator.
9584
+ * @returns WebElement of being used Web helper
9585
+ */
9586
+ grabWebElement(locator: CodeceptJS.LocatorOrString): Promise<any>;
9534
9587
  /**
9535
9588
  * Set [WebDriver timeouts](https://webdriver.io/docs/timeouts.html) in realtime.
9536
9589
  *
@@ -2824,6 +2824,7 @@ declare namespace CodeceptJS {
2824
2824
  * @property [recordHar] - record HAR and will be saved to `output/har`. See more of [HAR options](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har).
2825
2825
  * @property [testIdAttribute = data-testid] - locate elements based on the testIdAttribute. See more of [locate by test id](https://playwright.dev/docs/locators#locate-by-test-id).
2826
2826
  */
2827
+ // @ts-ignore
2827
2828
  type PlaywrightConfig = {
2828
2829
  url?: string;
2829
2830
  browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
@@ -6351,6 +6352,7 @@ declare namespace CodeceptJS {
6351
6352
  * @property [chrome] - pass additional [Puppeteer run options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
6352
6353
  * @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
6353
6354
  */
6355
+ // @ts-ignore
6354
6356
  type PuppeteerConfig = {
6355
6357
  url: string;
6356
6358
  basicAuth?: any;
@@ -6790,6 +6792,17 @@ declare namespace CodeceptJS {
6790
6792
  * {{ react }}
6791
6793
  */
6792
6794
  _locate(): void;
6795
+ /**
6796
+ * Get single element by different locator types, including strict locator
6797
+ * Should be used in custom helpers:
6798
+ *
6799
+ * ```js
6800
+ * const element = await this.helpers['Puppeteer']._locateElement({name: 'password'});
6801
+ * ```
6802
+ *
6803
+ * {{ react }}
6804
+ */
6805
+ _locateElement(): void;
6793
6806
  /**
6794
6807
  * Find a checkbox by providing human-readable text:
6795
6808
  * NOTE: Assumes the checkable element exists
@@ -6826,6 +6839,17 @@ declare namespace CodeceptJS {
6826
6839
  * @returns WebElement of being used Web helper
6827
6840
  */
6828
6841
  grabWebElements(locator: CodeceptJS.LocatorOrString): Promise<any>;
6842
+ /**
6843
+ * Grab WebElement for given locator
6844
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
6845
+ *
6846
+ * ```js
6847
+ * const webElement = await I.grabWebElement('#button');
6848
+ * ```
6849
+ * @param locator - element located by CSS|XPath|strict locator.
6850
+ * @returns WebElement of being used Web helper
6851
+ */
6852
+ grabWebElement(locator: CodeceptJS.LocatorOrString): Promise<any>;
6829
6853
  /**
6830
6854
  * Switch focus to a particular tab by its number. It waits tabs loading and then switch tab
6831
6855
  *
@@ -8281,6 +8305,22 @@ declare namespace CodeceptJS {
8281
8305
  */
8282
8306
  flushWebSocketMessages(): void;
8283
8307
  }
8308
+ /**
8309
+ * Find elements using Puppeteer's native element discovery methods
8310
+ * Note: Unlike Playwright, Puppeteer's Locator API doesn't have .all() method for multiple elements
8311
+ * @param matcher - Puppeteer context to search within
8312
+ * @param locator - Locator specification
8313
+ * @returns Array of ElementHandle objects
8314
+ */
8315
+ function findElements(matcher: any, locator: any | string): Promise<any[]>;
8316
+ /**
8317
+ * Find a single element using Puppeteer's native element discovery methods
8318
+ * Note: Puppeteer Locator API doesn't have .first() method like Playwright
8319
+ * @param matcher - Puppeteer context to search within
8320
+ * @param locator - Locator specification
8321
+ * @returns Single ElementHandle object
8322
+ */
8323
+ function findElement(matcher: any, locator: any | string): Promise<object>;
8284
8324
  /**
8285
8325
  * ## Configuration
8286
8326
  * @property [endpoint] - API base URL
@@ -8293,6 +8333,7 @@ declare namespace CodeceptJS {
8293
8333
  * @property [onResponse] - an async function which can update response object.
8294
8334
  * @property [maxUploadFileSize] - set the max content file size in MB when performing api calls.
8295
8335
  */
8336
+ // @ts-ignore
8296
8337
  type RESTConfig = {
8297
8338
  endpoint?: string;
8298
8339
  prettyPrintJson?: boolean;
@@ -9498,6 +9539,7 @@ declare namespace CodeceptJS {
9498
9539
  * @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
9499
9540
  * @property [logLevel = silent] - level of logging verbosity. Default: silent. Options: trace | debug | info | warn | error | silent. More info: https://webdriver.io/docs/configuration/#loglevel
9500
9541
  */
9542
+ // @ts-ignore
9501
9543
  type WebDriverConfig = {
9502
9544
  url: string;
9503
9545
  browser: string;
@@ -9968,6 +10010,17 @@ declare namespace CodeceptJS {
9968
10010
  * @returns WebElement of being used Web helper
9969
10011
  */
9970
10012
  grabWebElements(locator: CodeceptJS.LocatorOrString): Promise<any>;
10013
+ /**
10014
+ * Grab WebElement for given locator
10015
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
10016
+ *
10017
+ * ```js
10018
+ * const webElement = await I.grabWebElement('#button');
10019
+ * ```
10020
+ * @param locator - element located by CSS|XPath|strict locator.
10021
+ * @returns WebElement of being used Web helper
10022
+ */
10023
+ grabWebElement(locator: CodeceptJS.LocatorOrString): Promise<any>;
9971
10024
  /**
9972
10025
  * Set [WebDriver timeouts](https://webdriver.io/docs/timeouts.html) in realtime.
9973
10026
  *
@@ -11512,6 +11565,13 @@ declare namespace CodeceptJS {
11512
11565
  * Loads tests by pattern or by config.tests
11513
11566
  */
11514
11567
  loadTests(pattern?: string): void;
11568
+ /**
11569
+ * Apply sharding to test files based on shard configuration
11570
+ * @param testFiles - Array of test file paths
11571
+ * @param shardConfig - Shard configuration in format "index/total" (e.g., "1/4")
11572
+ * @returns - Filtered array of test files for this shard
11573
+ */
11574
+ _applySharding(testFiles: string[], shardConfig: string): string[];
11515
11575
  /**
11516
11576
  * Run a specific test or all loaded tests.
11517
11577
  */
@@ -12005,6 +12065,10 @@ declare namespace CodeceptJS {
12005
12065
  * Get a state of current queue and tasks
12006
12066
  */
12007
12067
  toString(): string;
12068
+ /**
12069
+ * Get current session ID
12070
+ */
12071
+ getCurrentSessionId(): string | null;
12008
12072
  }
12009
12073
  interface RecorderSession {
12010
12074
  running: boolean;
@@ -12118,6 +12182,10 @@ declare namespace CodeceptJS {
12118
12182
  function Feature(title: string, opts?: {
12119
12183
  [key: string]: any;
12120
12184
  }): FeatureConfig;
12185
+ /**
12186
+ * Exclusive test suite - runs only this feature.
12187
+ */
12188
+ const only: CodeceptJS.IFeature;
12121
12189
  /**
12122
12190
  * Pending test suite.
12123
12191
  */