codeceptjs 3.5.2 → 3.5.4-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.
@@ -0,0 +1,9 @@
1
+ module.exports = async function findReact(matcher, locator) {
2
+ let _locator = `_react=${locator.react}`;
3
+
4
+ if (locator.props && locator.props.name) {
5
+ _locator += `[name = "${locator.props.name}"]`;
6
+ }
7
+
8
+ return matcher.locator(_locator).all();
9
+ };
@@ -4,8 +4,6 @@ const standardActingHelpers = [
4
4
  'Puppeteer',
5
5
  'Appium',
6
6
  'TestCafe',
7
- 'Protractor',
8
- 'Nightmare',
9
7
  ];
10
8
 
11
9
  module.exports = standardActingHelpers;
@@ -51,7 +51,6 @@ let restartsSession;
51
51
  * }
52
52
  * ```
53
53
  *
54
- * Please note, this service can be used with Protractor helper as well!
55
54
  *
56
55
  * #### Sauce Service
57
56
  *
package/lib/recorder.js CHANGED
@@ -94,7 +94,8 @@ module.exports = {
94
94
  oldPromises = [];
95
95
  tasks = [];
96
96
  this.session.running = false;
97
- this.retries = [];
97
+ // reset this retries makes the retryFailedStep plugin won't work if there is Before/BeforeSuit block due to retries is undefined on Scenario
98
+ // this.retries = [];
98
99
  },
99
100
 
100
101
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.5.2",
3
+ "version": "3.5.4-beta.1",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",
@@ -40,7 +40,7 @@
40
40
  "lint": "eslint bin/ examples/ lib/ test/ translations/ runok.js",
41
41
  "lint-fix": "eslint bin/ examples/ lib/ test/ translations/ runok.js --fix",
42
42
  "docs": "./runok.js docs",
43
- "test:unit": "mocha test/unit --recursive",
43
+ "test:unit": "mocha test/unit --recursive --timeout 5000",
44
44
  "test:runner": "mocha test/runner --recursive --timeout 5000",
45
45
  "test": "npm run test:unit && npm run test:runner",
46
46
  "test:appium-quick": "mocha test/helper/Appium_test.js --grep 'quick'",
@@ -59,7 +59,7 @@
59
59
  "prepare": "husky install"
60
60
  },
61
61
  "dependencies": {
62
- "@codeceptjs/configure": "^0.8.0",
62
+ "@codeceptjs/configure": "^0.10.0",
63
63
  "@codeceptjs/helper": "^1.0.2",
64
64
  "@cucumber/cucumber-expressions": "^16",
65
65
  "@cucumber/gherkin": "^26",
@@ -116,26 +116,24 @@
116
116
  "documentation": "^12.3.0",
117
117
  "dtslint": "^4.1.6",
118
118
  "electron": "^25.2.0",
119
- "eslint": "^6.8.0",
119
+ "eslint": "^8.45.0",
120
120
  "eslint-config-airbnb-base": "^15.0.0",
121
121
  "eslint-plugin-import": "^2.25.4",
122
122
  "eslint-plugin-mocha": "^6.3.0",
123
123
  "expect": "^26.6.2",
124
124
  "express": "^4.17.2",
125
- "form-data": "^3.0.1",
126
125
  "graphql": "^14.6.0",
127
126
  "husky": "^8.0.1",
128
127
  "inquirer-test": "^2.0.1",
129
128
  "jsdoc": "^3.6.10",
130
129
  "jsdoc-typeof-plugin": "^1.0.0",
131
130
  "json-server": "^0.10.1",
132
- "nightmare": "^3.0.2",
133
131
  "playwright": "^1.35.1",
134
132
  "puppeteer": "^10.4.0",
135
133
  "qrcode-terminal": "^0.12.0",
136
134
  "rosie": "^2.1.0",
137
135
  "runok": "^0.9.2",
138
- "sinon": "^9.2.4",
136
+ "sinon": "^15.2.0",
139
137
  "sinon-chai": "^3.7.0",
140
138
  "testcafe": "^2.1.0",
141
139
  "ts-morph": "^3.1.3",
@@ -524,7 +524,6 @@ declare const After: CodeceptJS.IHook;
524
524
  declare const __: any
525
525
 
526
526
  interface Window {
527
- codeceptjs: typeof CodeceptJS.browserCodecept;
528
527
  resq: any;
529
528
  }
530
529
 
@@ -4519,6 +4519,133 @@ declare namespace CodeceptJS {
4519
4519
  * @param [handler] - a function to process reques
4520
4520
  */
4521
4521
  stopMockingRoute(url?: string | RegExp, handler?: (...params: any[]) => any): Promise<any>;
4522
+ /**
4523
+ * Starts recording of network traffic.
4524
+ * This also resets recorded network requests.
4525
+ *
4526
+ * ```js
4527
+ * I.startRecordingTraffic();
4528
+ * ```
4529
+ */
4530
+ startRecordingTraffic(): Promise<void>;
4531
+ /**
4532
+ * Grab the recording network traffics
4533
+ */
4534
+ grabRecordedNetworkTraffics(): Promise<any>;
4535
+ /**
4536
+ * Blocks traffic for URL.
4537
+ *
4538
+ * Examples:
4539
+ *
4540
+ * ```js
4541
+ * I.blockTraffic('http://example.com/css/style.css');
4542
+ * I.blockTraffic('http://example.com/css/*.css');
4543
+ * I.blockTraffic('http://example.com/**');
4544
+ * I.blockTraffic(/\.css$/);
4545
+ * ```
4546
+ * @param url - URL to block . URL can contain * for wildcards. Example: https://www.example.com** to block all traffic for that domain. Regexp are also supported.
4547
+ */
4548
+ blockTraffic(url: any): Promise<any>;
4549
+ /**
4550
+ * Mocks traffic for URL(s).
4551
+ * This is a powerful feature to manipulate network traffic. Can be used e.g. to stabilize your tests, speed up your tests or as a last resort to make some test scenarios even possible.
4552
+ *
4553
+ * Examples:
4554
+ *
4555
+ * ```js
4556
+ * I.mockTraffic('/api/users/1', '{ id: 1, name: 'John Doe' }');
4557
+ * I.mockTraffic('/api/users/*', JSON.stringify({ id: 1, name: 'John Doe' }));
4558
+ * I.mockTraffic([/^https://api.example.com/v1/, 'https://api.example.com/v2/**'], 'Internal Server Error', 'text/html');
4559
+ * ```
4560
+ * @param urls - string|Array These are the URL(s) to mock, e.g. "/fooapi/*" or "['/fooapi_1/*', '/barapi_2/*']". Regular expressions are also supported.
4561
+ * @param responseString - string The string to return in fake response's body.
4562
+ * @param contentType - Content type of fake response. If not specified default value 'application/json' is used.
4563
+ */
4564
+ mockTraffic(urls: any, responseString: any, contentType?: any): Promise<any>;
4565
+ /**
4566
+ * Resets all recorded network requests.
4567
+ */
4568
+ flushNetworkTraffics(): Promise<any>;
4569
+ /**
4570
+ * Stops recording of network traffic. Recorded traffic is not flashed.
4571
+ *
4572
+ * ```js
4573
+ * I.stopRecordingTraffic();
4574
+ * ```
4575
+ */
4576
+ stopRecordingTraffic(): Promise<any>;
4577
+ /**
4578
+ * Verifies that a certain request is part of network traffic.
4579
+ *
4580
+ * ```js
4581
+ * // checking the request url contains certain query strings
4582
+ * I.amOnPage('https://openai.com/blog/chatgpt');
4583
+ * I.startRecordingTraffic();
4584
+ * await I.seeTraffic({
4585
+ * name: 'sentry event',
4586
+ * url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
4587
+ * parameters: {
4588
+ * width: '1919',
4589
+ * height: '1138',
4590
+ * },
4591
+ * });
4592
+ * ```
4593
+ *
4594
+ * ```js
4595
+ * // checking the request url contains certain post data
4596
+ * I.amOnPage('https://openai.com/blog/chatgpt');
4597
+ * I.startRecordingTraffic();
4598
+ * await I.seeTraffic({
4599
+ * name: 'event',
4600
+ * url: 'https://cloudflareinsights.com/cdn-cgi/rum',
4601
+ * requestPostData: {
4602
+ * st: 2,
4603
+ * },
4604
+ * });
4605
+ * ```
4606
+ * @param opts - options when checking the traffic network.
4607
+ * @param opts.name - A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
4608
+ * @param opts.url - Expected URL of request in network traffic
4609
+ * @param [opts.parameters] - Expected parameters of that request in network traffic
4610
+ * @param [opts.requestPostData] - Expected that request contains post data in network traffic
4611
+ * @param [opts.timeout] - Timeout to wait for request in seconds. Default is 10 seconds.
4612
+ */
4613
+ seeTraffic(opts: {
4614
+ name: string;
4615
+ url: string;
4616
+ parameters?: any;
4617
+ requestPostData?: any;
4618
+ timeout?: number;
4619
+ }): Promise<any>;
4620
+ /**
4621
+ * Returns full URL of request matching parameter "urlMatch".
4622
+ * @param urlMatch - Expected URL of request in network traffic. Can be a string or a regular expression.
4623
+ *
4624
+ * Examples:
4625
+ *
4626
+ * ```js
4627
+ * I.grabTrafficUrl('https://api.example.com/session');
4628
+ * I.grabTrafficUrl(/session.*start/);
4629
+ * ```
4630
+ */
4631
+ grabTrafficUrl(urlMatch: string | RegExp): Promise<any>;
4632
+ /**
4633
+ * Verifies that a certain request is not part of network traffic.
4634
+ *
4635
+ * Examples:
4636
+ *
4637
+ * ```js
4638
+ * I.dontSeeTraffic({ name: 'Unexpected API Call', url: 'https://api.example.com' });
4639
+ * I.dontSeeTraffic({ name: 'Unexpected API Call of "user" endpoint', url: /api.example.com.*user/ });
4640
+ * ```
4641
+ * @param opts - options when checking the traffic network.
4642
+ * @param opts.name - A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
4643
+ * @param opts.url - Expected URL of request in network traffic. Can be a string or a regular expression.
4644
+ */
4645
+ dontSeeTraffic(opts: {
4646
+ name: string;
4647
+ url: string | RegExp;
4648
+ }): Promise<any>;
4522
4649
  }
4523
4650
  /**
4524
4651
  * This helper works the same as MockRequest helper. It has been included for backwards compatibility
@@ -4602,6 +4602,133 @@ declare namespace CodeceptJS {
4602
4602
  * @param [handler] - a function to process reques
4603
4603
  */
4604
4604
  stopMockingRoute(url?: string | RegExp, handler?: (...params: any[]) => any): void;
4605
+ /**
4606
+ * Starts recording of network traffic.
4607
+ * This also resets recorded network requests.
4608
+ *
4609
+ * ```js
4610
+ * I.startRecordingTraffic();
4611
+ * ```
4612
+ */
4613
+ startRecordingTraffic(): Promise<void>;
4614
+ /**
4615
+ * Grab the recording network traffics
4616
+ */
4617
+ grabRecordedNetworkTraffics(): any[];
4618
+ /**
4619
+ * Blocks traffic for URL.
4620
+ *
4621
+ * Examples:
4622
+ *
4623
+ * ```js
4624
+ * I.blockTraffic('http://example.com/css/style.css');
4625
+ * I.blockTraffic('http://example.com/css/*.css');
4626
+ * I.blockTraffic('http://example.com/**');
4627
+ * I.blockTraffic(/\.css$/);
4628
+ * ```
4629
+ * @param url - URL to block . URL can contain * for wildcards. Example: https://www.example.com** to block all traffic for that domain. Regexp are also supported.
4630
+ */
4631
+ blockTraffic(url: any): void;
4632
+ /**
4633
+ * Mocks traffic for URL(s).
4634
+ * This is a powerful feature to manipulate network traffic. Can be used e.g. to stabilize your tests, speed up your tests or as a last resort to make some test scenarios even possible.
4635
+ *
4636
+ * Examples:
4637
+ *
4638
+ * ```js
4639
+ * I.mockTraffic('/api/users/1', '{ id: 1, name: 'John Doe' }');
4640
+ * I.mockTraffic('/api/users/*', JSON.stringify({ id: 1, name: 'John Doe' }));
4641
+ * I.mockTraffic([/^https://api.example.com/v1/, 'https://api.example.com/v2/**'], 'Internal Server Error', 'text/html');
4642
+ * ```
4643
+ * @param urls - string|Array These are the URL(s) to mock, e.g. "/fooapi/*" or "['/fooapi_1/*', '/barapi_2/*']". Regular expressions are also supported.
4644
+ * @param responseString - string The string to return in fake response's body.
4645
+ * @param contentType - Content type of fake response. If not specified default value 'application/json' is used.
4646
+ */
4647
+ mockTraffic(urls: any, responseString: any, contentType?: any): void;
4648
+ /**
4649
+ * Resets all recorded network requests.
4650
+ */
4651
+ flushNetworkTraffics(): void;
4652
+ /**
4653
+ * Stops recording of network traffic. Recorded traffic is not flashed.
4654
+ *
4655
+ * ```js
4656
+ * I.stopRecordingTraffic();
4657
+ * ```
4658
+ */
4659
+ stopRecordingTraffic(): void;
4660
+ /**
4661
+ * Verifies that a certain request is part of network traffic.
4662
+ *
4663
+ * ```js
4664
+ * // checking the request url contains certain query strings
4665
+ * I.amOnPage('https://openai.com/blog/chatgpt');
4666
+ * I.startRecordingTraffic();
4667
+ * await I.seeTraffic({
4668
+ * name: 'sentry event',
4669
+ * url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
4670
+ * parameters: {
4671
+ * width: '1919',
4672
+ * height: '1138',
4673
+ * },
4674
+ * });
4675
+ * ```
4676
+ *
4677
+ * ```js
4678
+ * // checking the request url contains certain post data
4679
+ * I.amOnPage('https://openai.com/blog/chatgpt');
4680
+ * I.startRecordingTraffic();
4681
+ * await I.seeTraffic({
4682
+ * name: 'event',
4683
+ * url: 'https://cloudflareinsights.com/cdn-cgi/rum',
4684
+ * requestPostData: {
4685
+ * st: 2,
4686
+ * },
4687
+ * });
4688
+ * ```
4689
+ * @param opts - options when checking the traffic network.
4690
+ * @param opts.name - A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
4691
+ * @param opts.url - Expected URL of request in network traffic
4692
+ * @param [opts.parameters] - Expected parameters of that request in network traffic
4693
+ * @param [opts.requestPostData] - Expected that request contains post data in network traffic
4694
+ * @param [opts.timeout] - Timeout to wait for request in seconds. Default is 10 seconds.
4695
+ */
4696
+ seeTraffic(opts: {
4697
+ name: string;
4698
+ url: string;
4699
+ parameters?: any;
4700
+ requestPostData?: any;
4701
+ timeout?: number;
4702
+ }): Promise<any>;
4703
+ /**
4704
+ * Returns full URL of request matching parameter "urlMatch".
4705
+ * @param urlMatch - Expected URL of request in network traffic. Can be a string or a regular expression.
4706
+ *
4707
+ * Examples:
4708
+ *
4709
+ * ```js
4710
+ * I.grabTrafficUrl('https://api.example.com/session');
4711
+ * I.grabTrafficUrl(/session.*start/);
4712
+ * ```
4713
+ */
4714
+ grabTrafficUrl(urlMatch: string | RegExp): Promise<any>;
4715
+ /**
4716
+ * Verifies that a certain request is not part of network traffic.
4717
+ *
4718
+ * Examples:
4719
+ *
4720
+ * ```js
4721
+ * I.dontSeeTraffic({ name: 'Unexpected API Call', url: 'https://api.example.com' });
4722
+ * I.dontSeeTraffic({ name: 'Unexpected API Call of "user" endpoint', url: /api.example.com.*user/ });
4723
+ * ```
4724
+ * @param opts - options when checking the traffic network.
4725
+ * @param opts.name - A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
4726
+ * @param opts.url - Expected URL of request in network traffic. Can be a string or a regular expression.
4727
+ */
4728
+ dontSeeTraffic(opts: {
4729
+ name: string;
4730
+ url: string | RegExp;
4731
+ }): void;
4605
4732
  }
4606
4733
  /**
4607
4734
  * This helper works the same as MockRequest helper. It has been included for backwards compatibility
@@ -11114,31 +11241,6 @@ declare namespace CodeceptJS {
11114
11241
  */
11115
11242
  function cleanDispatcher(): void;
11116
11243
  }
11117
- namespace browserCodecept {
11118
- /**
11119
- * all found elements are stored here for reuse
11120
- */
11121
- var elements: Node[];
11122
- /**
11123
- * global context changer
11124
- */
11125
- var within: Node;
11126
- /**
11127
- * finders
11128
- */
11129
- function fetchElement(id: number): Node;
11130
- function findAndStoreElements(by: string, locator: CodeceptJS.ILocator, contextEl?: any): number[];
11131
- function findAndStoreElement(by: string, locator: CodeceptJS.ILocator, contextEl?: any): number | undefined;
11132
- function setWithin(by: string, locator: CodeceptJS.ILocator): void;
11133
- function findElements(by: string, locator: CodeceptJS.ILocator, contextEl?: any): Node[];
11134
- function findElement(by: string, locator: CodeceptJS.ILocator, context?: any): Node;
11135
- function clickEl(el: number): boolean;
11136
- function doubleClickEl(el: number): void;
11137
- function hoverEl(el: number, x: number | undefined, y: number | undefined): void;
11138
- function rightClickEl(el: number): void;
11139
- function checkEl(el: number): boolean | undefined;
11140
- function unCheckEl(el: number): boolean;
11141
- }
11142
11244
  /**
11143
11245
  * Index file for loading CodeceptJS programmatically.
11144
11246
  *