codeceptjs 3.5.15 → 3.6.0
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 +68 -31
- package/docs/webapi/startRecordingWebSocketMessages.mustache +8 -0
- package/docs/webapi/stopRecordingWebSocketMessages.mustache +7 -0
- package/lib/ai.js +152 -80
- package/lib/cli.js +1 -0
- package/lib/command/generate.js +34 -0
- package/lib/command/run-workers.js +3 -0
- package/lib/command/run.js +3 -0
- package/lib/container.js +2 -0
- package/lib/heal.js +172 -0
- package/lib/helper/{OpenAI.js → AI.js} +10 -12
- package/lib/helper/Playwright.js +32 -156
- package/lib/helper/Puppeteer.js +222 -3
- package/lib/helper/WebDriver.js +6 -144
- package/lib/helper/extras/PlaywrightReactVueLocator.js +6 -1
- package/lib/helper/network/actions.js +123 -0
- package/lib/helper/{networkTraffics → network}/utils.js +50 -0
- package/lib/index.js +3 -0
- package/lib/listener/steps.js +0 -2
- package/lib/locator.js +23 -1
- package/lib/plugin/heal.js +26 -117
- package/lib/recorder.js +11 -5
- package/lib/store.js +2 -0
- package/lib/template/heal.js +39 -0
- package/package.json +14 -15
- package/typings/index.d.ts +2 -2
- package/typings/promiseBasedTypes.d.ts +206 -25
- package/typings/types.d.ts +219 -26
|
@@ -1,4 +1,44 @@
|
|
|
1
1
|
declare namespace CodeceptJS {
|
|
2
|
+
/**
|
|
3
|
+
* AI Helper for CodeceptJS.
|
|
4
|
+
*
|
|
5
|
+
* This helper class provides integration with the AI GPT-3.5 or 4 language model for generating responses to questions or prompts within the context of web pages. It allows you to interact with the GPT-3.5 model to obtain intelligent responses based on HTML fragments or general prompts.
|
|
6
|
+
* This helper should be enabled with any web helpers like Playwright or Puppeteer or WebDrvier to ensure the HTML context is available.
|
|
7
|
+
*
|
|
8
|
+
* ## Configuration
|
|
9
|
+
*
|
|
10
|
+
* This helper should be configured in codecept.json or codecept.conf.js
|
|
11
|
+
*
|
|
12
|
+
* * `chunkSize`: (optional, default: 80000) - The maximum number of characters to send to the AI API at once. We split HTML fragments by 8000 chars to not exceed token limit. Increase this value if you use GPT-4.
|
|
13
|
+
*/
|
|
14
|
+
class AITs {
|
|
15
|
+
/**
|
|
16
|
+
* Asks the AI GPT language model a question based on the provided prompt within the context of the current page's HTML.
|
|
17
|
+
*
|
|
18
|
+
* ```js
|
|
19
|
+
* I.askGptOnPage('what does this page do?');
|
|
20
|
+
* ```
|
|
21
|
+
* @param prompt - The question or prompt to ask the GPT model.
|
|
22
|
+
* @returns - A Promise that resolves to the generated responses from the GPT model, joined by newlines.
|
|
23
|
+
*/
|
|
24
|
+
askGptOnPage(prompt: string): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Asks the AI a question based on the provided prompt within the context of a specific HTML fragment on the current page.
|
|
27
|
+
*
|
|
28
|
+
* ```js
|
|
29
|
+
* I.askGptOnPageFragment('describe features of this screen', '.screen');
|
|
30
|
+
* ```
|
|
31
|
+
* @param prompt - The question or prompt to ask the GPT-3.5 model.
|
|
32
|
+
* @param locator - The locator or selector used to identify the HTML fragment on the page.
|
|
33
|
+
* @returns - A Promise that resolves to the generated response from the GPT model.
|
|
34
|
+
*/
|
|
35
|
+
askGptOnPageFragment(prompt: string, locator: string): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Send a general request to ChatGPT and return response.
|
|
38
|
+
* @returns - A Promise that resolves to the generated response from the GPT model.
|
|
39
|
+
*/
|
|
40
|
+
askGptGeneralPrompt(prompt: string): Promise<string>;
|
|
41
|
+
}
|
|
2
42
|
/**
|
|
3
43
|
* Helper for managing remote data using REST API.
|
|
4
44
|
* Uses data generators like [rosie](https://github.com/rosiejs/rosie) or factory girl to create new record.
|
|
@@ -4709,7 +4749,7 @@ declare namespace CodeceptJS {
|
|
|
4709
4749
|
* ```
|
|
4710
4750
|
* This method allows intercepting and mocking requests & responses. [Learn more about it](https://playwright.dev/docs/network#handle-requests)
|
|
4711
4751
|
* @param [url] - URL, regex or pattern for to match URL
|
|
4712
|
-
* @param [handler] - a function to process
|
|
4752
|
+
* @param [handler] - a function to process request
|
|
4713
4753
|
*/
|
|
4714
4754
|
mockRoute(url?: string | RegExp, handler?: (...params: any[]) => any): Promise<any>;
|
|
4715
4755
|
/**
|
|
@@ -4721,7 +4761,7 @@ declare namespace CodeceptJS {
|
|
|
4721
4761
|
* ```
|
|
4722
4762
|
* If no handler is passed, all mock requests for the rote are disabled.
|
|
4723
4763
|
* @param [url] - URL, regex or pattern for to match URL
|
|
4724
|
-
* @param [handler] - a function to process
|
|
4764
|
+
* @param [handler] - a function to process request
|
|
4725
4765
|
*/
|
|
4726
4766
|
stopMockingRoute(url?: string | RegExp, handler?: (...params: any[]) => any): Promise<any>;
|
|
4727
4767
|
/**
|
|
@@ -4732,17 +4772,6 @@ declare namespace CodeceptJS {
|
|
|
4732
4772
|
* ```
|
|
4733
4773
|
*/
|
|
4734
4774
|
startRecordingTraffic(): Promise<any>;
|
|
4735
|
-
/**
|
|
4736
|
-
* Grab the recording network traffics
|
|
4737
|
-
*
|
|
4738
|
-
* ```js
|
|
4739
|
-
* const traffics = await I.grabRecordedNetworkTraffics();
|
|
4740
|
-
* expect(traffics[0].url).to.equal('https://reqres.in/api/comments/1');
|
|
4741
|
-
* expect(traffics[0].response.status).to.equal(200);
|
|
4742
|
-
* expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
|
|
4743
|
-
* ```
|
|
4744
|
-
*/
|
|
4745
|
-
grabRecordedNetworkTraffics(): Promise<any>;
|
|
4746
4775
|
/**
|
|
4747
4776
|
* Blocks traffic of a given URL or a list of URLs.
|
|
4748
4777
|
*
|
|
@@ -4793,6 +4822,29 @@ declare namespace CodeceptJS {
|
|
|
4793
4822
|
* ```
|
|
4794
4823
|
*/
|
|
4795
4824
|
stopRecordingTraffic(): Promise<any>;
|
|
4825
|
+
/**
|
|
4826
|
+
* Returns full URL of request matching parameter "urlMatch".
|
|
4827
|
+
* @param urlMatch - Expected URL of request in network traffic. Can be a string or a regular expression.
|
|
4828
|
+
*
|
|
4829
|
+
* Examples:
|
|
4830
|
+
*
|
|
4831
|
+
* ```js
|
|
4832
|
+
* I.grabTrafficUrl('https://api.example.com/session');
|
|
4833
|
+
* I.grabTrafficUrl(/session.*start/);
|
|
4834
|
+
* ```
|
|
4835
|
+
*/
|
|
4836
|
+
grabTrafficUrl(urlMatch: string | RegExp): Promise<any>;
|
|
4837
|
+
/**
|
|
4838
|
+
* Grab the recording network traffics
|
|
4839
|
+
*
|
|
4840
|
+
* ```js
|
|
4841
|
+
* const traffics = await I.grabRecordedNetworkTraffics();
|
|
4842
|
+
* expect(traffics[0].url).to.equal('https://reqres.in/api/comments/1');
|
|
4843
|
+
* expect(traffics[0].response.status).to.equal(200);
|
|
4844
|
+
* expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
|
|
4845
|
+
* ```
|
|
4846
|
+
*/
|
|
4847
|
+
grabRecordedNetworkTraffics(): Promise<any>;
|
|
4796
4848
|
/**
|
|
4797
4849
|
* Verifies that a certain request is part of network traffic.
|
|
4798
4850
|
*
|
|
@@ -4836,18 +4888,6 @@ declare namespace CodeceptJS {
|
|
|
4836
4888
|
requestPostData?: any;
|
|
4837
4889
|
timeout?: number;
|
|
4838
4890
|
}): Promise<any>;
|
|
4839
|
-
/**
|
|
4840
|
-
* Returns full URL of request matching parameter "urlMatch".
|
|
4841
|
-
* @param urlMatch - Expected URL of request in network traffic. Can be a string or a regular expression.
|
|
4842
|
-
*
|
|
4843
|
-
* Examples:
|
|
4844
|
-
*
|
|
4845
|
-
* ```js
|
|
4846
|
-
* I.grabTrafficUrl('https://api.example.com/session');
|
|
4847
|
-
* I.grabTrafficUrl(/session.*start/);
|
|
4848
|
-
* ```
|
|
4849
|
-
*/
|
|
4850
|
-
grabTrafficUrl(urlMatch: string | RegExp): Promise<any>;
|
|
4851
4891
|
/**
|
|
4852
4892
|
* Verifies that a certain request is not part of network traffic.
|
|
4853
4893
|
*
|
|
@@ -7824,6 +7864,147 @@ declare namespace CodeceptJS {
|
|
|
7824
7864
|
* @returns Element bounding rectangle
|
|
7825
7865
|
*/
|
|
7826
7866
|
grabElementBoundingRect(locator: LocatorOrString, elementSize?: string): Promise<DOMRect> | Promise<number>;
|
|
7867
|
+
/**
|
|
7868
|
+
* Mocks network request using [`Request Interception`](https://pptr.dev/next/guides/request-interception)
|
|
7869
|
+
*
|
|
7870
|
+
* ```js
|
|
7871
|
+
* I.mockRoute(/(\.png$)|(\.jpg$)/, route => route.abort());
|
|
7872
|
+
* ```
|
|
7873
|
+
* This method allows intercepting and mocking requests & responses. [Learn more about it](https://pptr.dev/next/guides/request-interception)
|
|
7874
|
+
* @param [url] - URL, regex or pattern for to match URL
|
|
7875
|
+
* @param [handler] - a function to process request
|
|
7876
|
+
*/
|
|
7877
|
+
mockRoute(url?: string | RegExp, handler?: (...params: any[]) => any): Promise<any>;
|
|
7878
|
+
/**
|
|
7879
|
+
* Stops network mocking created by `mockRoute`.
|
|
7880
|
+
*
|
|
7881
|
+
* ```js
|
|
7882
|
+
* I.stopMockingRoute(/(\.png$)|(\.jpg$)/);
|
|
7883
|
+
* ```
|
|
7884
|
+
* @param [url] - URL, regex or pattern for to match URL
|
|
7885
|
+
*/
|
|
7886
|
+
stopMockingRoute(url?: string | RegExp): Promise<any>;
|
|
7887
|
+
/**
|
|
7888
|
+
* Resets all recorded network requests.
|
|
7889
|
+
*
|
|
7890
|
+
* ```js
|
|
7891
|
+
* I.flushNetworkTraffics();
|
|
7892
|
+
* ```
|
|
7893
|
+
*/
|
|
7894
|
+
flushNetworkTraffics(): Promise<any>;
|
|
7895
|
+
/**
|
|
7896
|
+
* Stops recording of network traffic. Recorded traffic is not flashed.
|
|
7897
|
+
*
|
|
7898
|
+
* ```js
|
|
7899
|
+
* I.stopRecordingTraffic();
|
|
7900
|
+
* ```
|
|
7901
|
+
*/
|
|
7902
|
+
stopRecordingTraffic(): Promise<any>;
|
|
7903
|
+
/**
|
|
7904
|
+
* Starts recording the network traffics.
|
|
7905
|
+
* This also resets recorded network requests.
|
|
7906
|
+
*
|
|
7907
|
+
* ```js
|
|
7908
|
+
* I.startRecordingTraffic();
|
|
7909
|
+
* ```
|
|
7910
|
+
*/
|
|
7911
|
+
startRecordingTraffic(): Promise<any>;
|
|
7912
|
+
/**
|
|
7913
|
+
* Grab the recording network traffics
|
|
7914
|
+
*
|
|
7915
|
+
* ```js
|
|
7916
|
+
* const traffics = await I.grabRecordedNetworkTraffics();
|
|
7917
|
+
* expect(traffics[0].url).to.equal('https://reqres.in/api/comments/1');
|
|
7918
|
+
* expect(traffics[0].response.status).to.equal(200);
|
|
7919
|
+
* expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
|
|
7920
|
+
* ```
|
|
7921
|
+
*/
|
|
7922
|
+
grabRecordedNetworkTraffics(): Promise<any>;
|
|
7923
|
+
/**
|
|
7924
|
+
* Verifies that a certain request is part of network traffic.
|
|
7925
|
+
*
|
|
7926
|
+
* ```js
|
|
7927
|
+
* // checking the request url contains certain query strings
|
|
7928
|
+
* I.amOnPage('https://openai.com/blog/chatgpt');
|
|
7929
|
+
* I.startRecordingTraffic();
|
|
7930
|
+
* await I.seeTraffic({
|
|
7931
|
+
* name: 'sentry event',
|
|
7932
|
+
* url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
|
|
7933
|
+
* parameters: {
|
|
7934
|
+
* width: '1919',
|
|
7935
|
+
* height: '1138',
|
|
7936
|
+
* },
|
|
7937
|
+
* });
|
|
7938
|
+
* ```
|
|
7939
|
+
*
|
|
7940
|
+
* ```js
|
|
7941
|
+
* // checking the request url contains certain post data
|
|
7942
|
+
* I.amOnPage('https://openai.com/blog/chatgpt');
|
|
7943
|
+
* I.startRecordingTraffic();
|
|
7944
|
+
* await I.seeTraffic({
|
|
7945
|
+
* name: 'event',
|
|
7946
|
+
* url: 'https://cloudflareinsights.com/cdn-cgi/rum',
|
|
7947
|
+
* requestPostData: {
|
|
7948
|
+
* st: 2,
|
|
7949
|
+
* },
|
|
7950
|
+
* });
|
|
7951
|
+
* ```
|
|
7952
|
+
* @param opts - options when checking the traffic network.
|
|
7953
|
+
* @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.
|
|
7954
|
+
* @param opts.url - Expected URL of request in network traffic
|
|
7955
|
+
* @param [opts.parameters] - Expected parameters of that request in network traffic
|
|
7956
|
+
* @param [opts.requestPostData] - Expected that request contains post data in network traffic
|
|
7957
|
+
* @param [opts.timeout] - Timeout to wait for request in seconds. Default is 10 seconds.
|
|
7958
|
+
*/
|
|
7959
|
+
seeTraffic(opts: {
|
|
7960
|
+
name: string;
|
|
7961
|
+
url: string;
|
|
7962
|
+
parameters?: any;
|
|
7963
|
+
requestPostData?: any;
|
|
7964
|
+
timeout?: number;
|
|
7965
|
+
}): Promise<any>;
|
|
7966
|
+
/**
|
|
7967
|
+
* Verifies that a certain request is not part of network traffic.
|
|
7968
|
+
*
|
|
7969
|
+
* Examples:
|
|
7970
|
+
*
|
|
7971
|
+
* ```js
|
|
7972
|
+
* I.dontSeeTraffic({ name: 'Unexpected API Call', url: 'https://api.example.com' });
|
|
7973
|
+
* I.dontSeeTraffic({ name: 'Unexpected API Call of "user" endpoint', url: /api.example.com.*user/ });
|
|
7974
|
+
* ```
|
|
7975
|
+
* @param opts - options when checking the traffic network.
|
|
7976
|
+
* @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.
|
|
7977
|
+
* @param opts.url - Expected URL of request in network traffic. Can be a string or a regular expression.
|
|
7978
|
+
*/
|
|
7979
|
+
dontSeeTraffic(opts: {
|
|
7980
|
+
name: string;
|
|
7981
|
+
url: string | RegExp;
|
|
7982
|
+
}): Promise<any>;
|
|
7983
|
+
/**
|
|
7984
|
+
* Starts recording of websocket messages.
|
|
7985
|
+
* This also resets recorded websocket messages.
|
|
7986
|
+
*
|
|
7987
|
+
* ```js
|
|
7988
|
+
* await I.startRecordingWebSocketMessages();
|
|
7989
|
+
* ```
|
|
7990
|
+
*/
|
|
7991
|
+
startRecordingWebSocketMessages(): Promise<any>;
|
|
7992
|
+
/**
|
|
7993
|
+
* Stops recording WS messages. Recorded WS messages is not flashed.
|
|
7994
|
+
*
|
|
7995
|
+
* ```js
|
|
7996
|
+
* await I.stopRecordingWebSocketMessages();
|
|
7997
|
+
* ```
|
|
7998
|
+
*/
|
|
7999
|
+
stopRecordingWebSocketMessages(): Promise<any>;
|
|
8000
|
+
/**
|
|
8001
|
+
* Grab the recording WS messages
|
|
8002
|
+
*/
|
|
8003
|
+
grabWebSocketMessages(): Promise<any>;
|
|
8004
|
+
/**
|
|
8005
|
+
* Resets all recorded WS messages.
|
|
8006
|
+
*/
|
|
8007
|
+
flushWebSocketMessages(): Promise<any>;
|
|
7827
8008
|
}
|
|
7828
8009
|
/**
|
|
7829
8010
|
* REST helper allows to send additional requests to the REST API during acceptance tests.
|
package/typings/types.d.ts
CHANGED
|
@@ -1,4 +1,44 @@
|
|
|
1
1
|
declare namespace CodeceptJS {
|
|
2
|
+
/**
|
|
3
|
+
* AI Helper for CodeceptJS.
|
|
4
|
+
*
|
|
5
|
+
* This helper class provides integration with the AI GPT-3.5 or 4 language model for generating responses to questions or prompts within the context of web pages. It allows you to interact with the GPT-3.5 model to obtain intelligent responses based on HTML fragments or general prompts.
|
|
6
|
+
* This helper should be enabled with any web helpers like Playwright or Puppeteer or WebDrvier to ensure the HTML context is available.
|
|
7
|
+
*
|
|
8
|
+
* ## Configuration
|
|
9
|
+
*
|
|
10
|
+
* This helper should be configured in codecept.json or codecept.conf.js
|
|
11
|
+
*
|
|
12
|
+
* * `chunkSize`: (optional, default: 80000) - The maximum number of characters to send to the AI API at once. We split HTML fragments by 8000 chars to not exceed token limit. Increase this value if you use GPT-4.
|
|
13
|
+
*/
|
|
14
|
+
class AI {
|
|
15
|
+
/**
|
|
16
|
+
* Asks the AI GPT language model a question based on the provided prompt within the context of the current page's HTML.
|
|
17
|
+
*
|
|
18
|
+
* ```js
|
|
19
|
+
* I.askGptOnPage('what does this page do?');
|
|
20
|
+
* ```
|
|
21
|
+
* @param prompt - The question or prompt to ask the GPT model.
|
|
22
|
+
* @returns - A Promise that resolves to the generated responses from the GPT model, joined by newlines.
|
|
23
|
+
*/
|
|
24
|
+
askGptOnPage(prompt: string): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Asks the AI a question based on the provided prompt within the context of a specific HTML fragment on the current page.
|
|
27
|
+
*
|
|
28
|
+
* ```js
|
|
29
|
+
* I.askGptOnPageFragment('describe features of this screen', '.screen');
|
|
30
|
+
* ```
|
|
31
|
+
* @param prompt - The question or prompt to ask the GPT-3.5 model.
|
|
32
|
+
* @param locator - The locator or selector used to identify the HTML fragment on the page.
|
|
33
|
+
* @returns - A Promise that resolves to the generated response from the GPT model.
|
|
34
|
+
*/
|
|
35
|
+
askGptOnPageFragment(prompt: string, locator: string): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Send a general request to ChatGPT and return response.
|
|
38
|
+
* @returns - A Promise that resolves to the generated response from the GPT model.
|
|
39
|
+
*/
|
|
40
|
+
askGptGeneralPrompt(prompt: string): Promise<string>;
|
|
41
|
+
}
|
|
2
42
|
/**
|
|
3
43
|
* Helper for managing remote data using REST API.
|
|
4
44
|
* Uses data generators like [rosie](https://github.com/rosiejs/rosie) or factory girl to create new record.
|
|
@@ -3028,6 +3068,7 @@ declare namespace CodeceptJS {
|
|
|
3028
3068
|
* @property [bypassCSP] - bypass Content Security Policy or CSP
|
|
3029
3069
|
* @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
3030
3070
|
* @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).
|
|
3071
|
+
* @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).
|
|
3031
3072
|
*/
|
|
3032
3073
|
type PlaywrightConfig = {
|
|
3033
3074
|
url?: string;
|
|
@@ -3065,6 +3106,7 @@ declare namespace CodeceptJS {
|
|
|
3065
3106
|
bypassCSP?: boolean;
|
|
3066
3107
|
highlightElement?: boolean;
|
|
3067
3108
|
recordHar?: any;
|
|
3109
|
+
testIdAttribute?: string;
|
|
3068
3110
|
};
|
|
3069
3111
|
/**
|
|
3070
3112
|
* Uses [Playwright](https://github.com/microsoft/playwright) library to run tests inside:
|
|
@@ -4957,7 +4999,7 @@ declare namespace CodeceptJS {
|
|
|
4957
4999
|
* ```
|
|
4958
5000
|
* This method allows intercepting and mocking requests & responses. [Learn more about it](https://playwright.dev/docs/network#handle-requests)
|
|
4959
5001
|
* @param [url] - URL, regex or pattern for to match URL
|
|
4960
|
-
* @param [handler] - a function to process
|
|
5002
|
+
* @param [handler] - a function to process request
|
|
4961
5003
|
*/
|
|
4962
5004
|
mockRoute(url?: string | RegExp, handler?: (...params: any[]) => any): void;
|
|
4963
5005
|
/**
|
|
@@ -4969,7 +5011,7 @@ declare namespace CodeceptJS {
|
|
|
4969
5011
|
* ```
|
|
4970
5012
|
* If no handler is passed, all mock requests for the rote are disabled.
|
|
4971
5013
|
* @param [url] - URL, regex or pattern for to match URL
|
|
4972
|
-
* @param [handler] - a function to process
|
|
5014
|
+
* @param [handler] - a function to process request
|
|
4973
5015
|
*/
|
|
4974
5016
|
stopMockingRoute(url?: string | RegExp, handler?: (...params: any[]) => any): void;
|
|
4975
5017
|
/**
|
|
@@ -4980,18 +5022,6 @@ declare namespace CodeceptJS {
|
|
|
4980
5022
|
* ```
|
|
4981
5023
|
*/
|
|
4982
5024
|
startRecordingTraffic(): void;
|
|
4983
|
-
/**
|
|
4984
|
-
* Grab the recording network traffics
|
|
4985
|
-
*
|
|
4986
|
-
* ```js
|
|
4987
|
-
* const traffics = await I.grabRecordedNetworkTraffics();
|
|
4988
|
-
* expect(traffics[0].url).to.equal('https://reqres.in/api/comments/1');
|
|
4989
|
-
* expect(traffics[0].response.status).to.equal(200);
|
|
4990
|
-
* expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
|
|
4991
|
-
* ```
|
|
4992
|
-
* @returns recorded network traffics
|
|
4993
|
-
*/
|
|
4994
|
-
grabRecordedNetworkTraffics(): any[];
|
|
4995
5025
|
/**
|
|
4996
5026
|
* Blocks traffic of a given URL or a list of URLs.
|
|
4997
5027
|
*
|
|
@@ -5042,6 +5072,30 @@ declare namespace CodeceptJS {
|
|
|
5042
5072
|
* ```
|
|
5043
5073
|
*/
|
|
5044
5074
|
stopRecordingTraffic(): void;
|
|
5075
|
+
/**
|
|
5076
|
+
* Returns full URL of request matching parameter "urlMatch".
|
|
5077
|
+
* @param urlMatch - Expected URL of request in network traffic. Can be a string or a regular expression.
|
|
5078
|
+
*
|
|
5079
|
+
* Examples:
|
|
5080
|
+
*
|
|
5081
|
+
* ```js
|
|
5082
|
+
* I.grabTrafficUrl('https://api.example.com/session');
|
|
5083
|
+
* I.grabTrafficUrl(/session.*start/);
|
|
5084
|
+
* ```
|
|
5085
|
+
*/
|
|
5086
|
+
grabTrafficUrl(urlMatch: string | RegExp): Promise<any>;
|
|
5087
|
+
/**
|
|
5088
|
+
* Grab the recording network traffics
|
|
5089
|
+
*
|
|
5090
|
+
* ```js
|
|
5091
|
+
* const traffics = await I.grabRecordedNetworkTraffics();
|
|
5092
|
+
* expect(traffics[0].url).to.equal('https://reqres.in/api/comments/1');
|
|
5093
|
+
* expect(traffics[0].response.status).to.equal(200);
|
|
5094
|
+
* expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
|
|
5095
|
+
* ```
|
|
5096
|
+
* @returns recorded network traffics
|
|
5097
|
+
*/
|
|
5098
|
+
grabRecordedNetworkTraffics(): any[];
|
|
5045
5099
|
/**
|
|
5046
5100
|
* Verifies that a certain request is part of network traffic.
|
|
5047
5101
|
*
|
|
@@ -5086,18 +5140,6 @@ declare namespace CodeceptJS {
|
|
|
5086
5140
|
requestPostData?: any;
|
|
5087
5141
|
timeout?: number;
|
|
5088
5142
|
}): void;
|
|
5089
|
-
/**
|
|
5090
|
-
* Returns full URL of request matching parameter "urlMatch".
|
|
5091
|
-
* @param urlMatch - Expected URL of request in network traffic. Can be a string or a regular expression.
|
|
5092
|
-
*
|
|
5093
|
-
* Examples:
|
|
5094
|
-
*
|
|
5095
|
-
* ```js
|
|
5096
|
-
* I.grabTrafficUrl('https://api.example.com/session');
|
|
5097
|
-
* I.grabTrafficUrl(/session.*start/);
|
|
5098
|
-
* ```
|
|
5099
|
-
*/
|
|
5100
|
-
grabTrafficUrl(urlMatch: string | RegExp): Promise<any>;
|
|
5101
5143
|
/**
|
|
5102
5144
|
* Verifies that a certain request is not part of network traffic.
|
|
5103
5145
|
*
|
|
@@ -5123,6 +5165,7 @@ declare namespace CodeceptJS {
|
|
|
5123
5165
|
* ```js
|
|
5124
5166
|
* await I.startRecordingWebSocketMessages();
|
|
5125
5167
|
* ```
|
|
5168
|
+
* @returns automatically synchronized promise through #recorder
|
|
5126
5169
|
*/
|
|
5127
5170
|
startRecordingWebSocketMessages(): void;
|
|
5128
5171
|
/**
|
|
@@ -5131,6 +5174,7 @@ declare namespace CodeceptJS {
|
|
|
5131
5174
|
* ```js
|
|
5132
5175
|
* await I.stopRecordingWebSocketMessages();
|
|
5133
5176
|
* ```
|
|
5177
|
+
* @returns automatically synchronized promise through #recorder
|
|
5134
5178
|
*/
|
|
5135
5179
|
stopRecordingWebSocketMessages(): void;
|
|
5136
5180
|
/**
|
|
@@ -8325,6 +8369,153 @@ declare namespace CodeceptJS {
|
|
|
8325
8369
|
* @returns Element bounding rectangle
|
|
8326
8370
|
*/
|
|
8327
8371
|
grabElementBoundingRect(locator: LocatorOrString, elementSize?: string): Promise<DOMRect> | Promise<number>;
|
|
8372
|
+
/**
|
|
8373
|
+
* Mocks network request using [`Request Interception`](https://pptr.dev/next/guides/request-interception)
|
|
8374
|
+
*
|
|
8375
|
+
* ```js
|
|
8376
|
+
* I.mockRoute(/(\.png$)|(\.jpg$)/, route => route.abort());
|
|
8377
|
+
* ```
|
|
8378
|
+
* This method allows intercepting and mocking requests & responses. [Learn more about it](https://pptr.dev/next/guides/request-interception)
|
|
8379
|
+
* @param [url] - URL, regex or pattern for to match URL
|
|
8380
|
+
* @param [handler] - a function to process request
|
|
8381
|
+
*/
|
|
8382
|
+
mockRoute(url?: string | RegExp, handler?: (...params: any[]) => any): void;
|
|
8383
|
+
/**
|
|
8384
|
+
* Stops network mocking created by `mockRoute`.
|
|
8385
|
+
*
|
|
8386
|
+
* ```js
|
|
8387
|
+
* I.stopMockingRoute(/(\.png$)|(\.jpg$)/);
|
|
8388
|
+
* ```
|
|
8389
|
+
* @param [url] - URL, regex or pattern for to match URL
|
|
8390
|
+
*/
|
|
8391
|
+
stopMockingRoute(url?: string | RegExp): void;
|
|
8392
|
+
/**
|
|
8393
|
+
* Resets all recorded network requests.
|
|
8394
|
+
*
|
|
8395
|
+
* ```js
|
|
8396
|
+
* I.flushNetworkTraffics();
|
|
8397
|
+
* ```
|
|
8398
|
+
*/
|
|
8399
|
+
flushNetworkTraffics(): void;
|
|
8400
|
+
/**
|
|
8401
|
+
* Stops recording of network traffic. Recorded traffic is not flashed.
|
|
8402
|
+
*
|
|
8403
|
+
* ```js
|
|
8404
|
+
* I.stopRecordingTraffic();
|
|
8405
|
+
* ```
|
|
8406
|
+
*/
|
|
8407
|
+
stopRecordingTraffic(): void;
|
|
8408
|
+
/**
|
|
8409
|
+
* Starts recording the network traffics.
|
|
8410
|
+
* This also resets recorded network requests.
|
|
8411
|
+
*
|
|
8412
|
+
* ```js
|
|
8413
|
+
* I.startRecordingTraffic();
|
|
8414
|
+
* ```
|
|
8415
|
+
* @returns automatically synchronized promise through #recorder
|
|
8416
|
+
*/
|
|
8417
|
+
startRecordingTraffic(): void;
|
|
8418
|
+
/**
|
|
8419
|
+
* Grab the recording network traffics
|
|
8420
|
+
*
|
|
8421
|
+
* ```js
|
|
8422
|
+
* const traffics = await I.grabRecordedNetworkTraffics();
|
|
8423
|
+
* expect(traffics[0].url).to.equal('https://reqres.in/api/comments/1');
|
|
8424
|
+
* expect(traffics[0].response.status).to.equal(200);
|
|
8425
|
+
* expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
|
|
8426
|
+
* ```
|
|
8427
|
+
* @returns recorded network traffics
|
|
8428
|
+
*/
|
|
8429
|
+
grabRecordedNetworkTraffics(): any[];
|
|
8430
|
+
/**
|
|
8431
|
+
* Verifies that a certain request is part of network traffic.
|
|
8432
|
+
*
|
|
8433
|
+
* ```js
|
|
8434
|
+
* // checking the request url contains certain query strings
|
|
8435
|
+
* I.amOnPage('https://openai.com/blog/chatgpt');
|
|
8436
|
+
* I.startRecordingTraffic();
|
|
8437
|
+
* await I.seeTraffic({
|
|
8438
|
+
* name: 'sentry event',
|
|
8439
|
+
* url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
|
|
8440
|
+
* parameters: {
|
|
8441
|
+
* width: '1919',
|
|
8442
|
+
* height: '1138',
|
|
8443
|
+
* },
|
|
8444
|
+
* });
|
|
8445
|
+
* ```
|
|
8446
|
+
*
|
|
8447
|
+
* ```js
|
|
8448
|
+
* // checking the request url contains certain post data
|
|
8449
|
+
* I.amOnPage('https://openai.com/blog/chatgpt');
|
|
8450
|
+
* I.startRecordingTraffic();
|
|
8451
|
+
* await I.seeTraffic({
|
|
8452
|
+
* name: 'event',
|
|
8453
|
+
* url: 'https://cloudflareinsights.com/cdn-cgi/rum',
|
|
8454
|
+
* requestPostData: {
|
|
8455
|
+
* st: 2,
|
|
8456
|
+
* },
|
|
8457
|
+
* });
|
|
8458
|
+
* ```
|
|
8459
|
+
* @param opts - options when checking the traffic network.
|
|
8460
|
+
* @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.
|
|
8461
|
+
* @param opts.url - Expected URL of request in network traffic
|
|
8462
|
+
* @param [opts.parameters] - Expected parameters of that request in network traffic
|
|
8463
|
+
* @param [opts.requestPostData] - Expected that request contains post data in network traffic
|
|
8464
|
+
* @param [opts.timeout] - Timeout to wait for request in seconds. Default is 10 seconds.
|
|
8465
|
+
* @returns automatically synchronized promise through #recorder
|
|
8466
|
+
*/
|
|
8467
|
+
seeTraffic(opts: {
|
|
8468
|
+
name: string;
|
|
8469
|
+
url: string;
|
|
8470
|
+
parameters?: any;
|
|
8471
|
+
requestPostData?: any;
|
|
8472
|
+
timeout?: number;
|
|
8473
|
+
}): void;
|
|
8474
|
+
/**
|
|
8475
|
+
* Verifies that a certain request is not part of network traffic.
|
|
8476
|
+
*
|
|
8477
|
+
* Examples:
|
|
8478
|
+
*
|
|
8479
|
+
* ```js
|
|
8480
|
+
* I.dontSeeTraffic({ name: 'Unexpected API Call', url: 'https://api.example.com' });
|
|
8481
|
+
* I.dontSeeTraffic({ name: 'Unexpected API Call of "user" endpoint', url: /api.example.com.*user/ });
|
|
8482
|
+
* ```
|
|
8483
|
+
* @param opts - options when checking the traffic network.
|
|
8484
|
+
* @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.
|
|
8485
|
+
* @param opts.url - Expected URL of request in network traffic. Can be a string or a regular expression.
|
|
8486
|
+
* @returns automatically synchronized promise through #recorder
|
|
8487
|
+
*/
|
|
8488
|
+
dontSeeTraffic(opts: {
|
|
8489
|
+
name: string;
|
|
8490
|
+
url: string | RegExp;
|
|
8491
|
+
}): void;
|
|
8492
|
+
/**
|
|
8493
|
+
* Starts recording of websocket messages.
|
|
8494
|
+
* This also resets recorded websocket messages.
|
|
8495
|
+
*
|
|
8496
|
+
* ```js
|
|
8497
|
+
* await I.startRecordingWebSocketMessages();
|
|
8498
|
+
* ```
|
|
8499
|
+
* @returns automatically synchronized promise through #recorder
|
|
8500
|
+
*/
|
|
8501
|
+
startRecordingWebSocketMessages(): void;
|
|
8502
|
+
/**
|
|
8503
|
+
* Stops recording WS messages. Recorded WS messages is not flashed.
|
|
8504
|
+
*
|
|
8505
|
+
* ```js
|
|
8506
|
+
* await I.stopRecordingWebSocketMessages();
|
|
8507
|
+
* ```
|
|
8508
|
+
* @returns automatically synchronized promise through #recorder
|
|
8509
|
+
*/
|
|
8510
|
+
stopRecordingWebSocketMessages(): void;
|
|
8511
|
+
/**
|
|
8512
|
+
* Grab the recording WS messages
|
|
8513
|
+
*/
|
|
8514
|
+
grabWebSocketMessages(): any[] | undefined;
|
|
8515
|
+
/**
|
|
8516
|
+
* Resets all recorded WS messages.
|
|
8517
|
+
*/
|
|
8518
|
+
flushWebSocketMessages(): void;
|
|
8328
8519
|
}
|
|
8329
8520
|
/**
|
|
8330
8521
|
* ## Configuration
|
|
@@ -11933,6 +12124,7 @@ declare namespace CodeceptJS {
|
|
|
11933
12124
|
isShadow(): boolean;
|
|
11934
12125
|
isFrame(): boolean;
|
|
11935
12126
|
isCSS(): boolean;
|
|
12127
|
+
isPlaywrightLocator(): boolean;
|
|
11936
12128
|
isNull(): boolean;
|
|
11937
12129
|
isXPath(): boolean;
|
|
11938
12130
|
isCustom(): boolean;
|
|
@@ -12157,6 +12349,7 @@ declare namespace CodeceptJS {
|
|
|
12157
12349
|
namespace store {
|
|
12158
12350
|
var debugMode: boolean;
|
|
12159
12351
|
var timeouts: boolean;
|
|
12352
|
+
var dryRun: boolean;
|
|
12160
12353
|
}
|
|
12161
12354
|
/**
|
|
12162
12355
|
* Describe a "suite" with the given `title`
|