codeceptjs 3.2.0 → 3.3.0-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.
Files changed (74) hide show
  1. package/CHANGELOG.md +78 -2
  2. package/docs/advanced.md +3 -3
  3. package/docs/api.md +227 -188
  4. package/docs/basics.md +26 -1
  5. package/docs/bdd.md +2 -2
  6. package/docs/build/ApiDataFactory.js +13 -6
  7. package/docs/build/Appium.js +98 -36
  8. package/docs/build/FileSystem.js +11 -1
  9. package/docs/build/GraphQL.js +11 -0
  10. package/docs/build/JSONResponse.js +297 -0
  11. package/docs/build/Nightmare.js +48 -48
  12. package/docs/build/Playwright.js +277 -151
  13. package/docs/build/Puppeteer.js +77 -68
  14. package/docs/build/REST.js +36 -0
  15. package/docs/build/TestCafe.js +44 -44
  16. package/docs/build/WebDriver.js +70 -70
  17. package/docs/changelog.md +28 -2
  18. package/docs/configuration.md +8 -8
  19. package/docs/custom-helpers.md +1 -1
  20. package/docs/data.md +9 -9
  21. package/docs/helpers/ApiDataFactory.md +7 -0
  22. package/docs/helpers/Appium.md +240 -198
  23. package/docs/helpers/FileSystem.md +11 -1
  24. package/docs/helpers/JSONResponse.md +230 -0
  25. package/docs/helpers/Playwright.md +283 -216
  26. package/docs/helpers/Puppeteer.md +9 -1
  27. package/docs/helpers/REST.md +30 -9
  28. package/docs/installation.md +3 -1
  29. package/docs/internal-api.md +265 -0
  30. package/docs/mobile.md +11 -11
  31. package/docs/nightmare.md +3 -3
  32. package/docs/pageobjects.md +2 -0
  33. package/docs/playwright.md +73 -18
  34. package/docs/plugins.md +140 -40
  35. package/docs/puppeteer.md +28 -12
  36. package/docs/quickstart.md +2 -3
  37. package/docs/reports.md +44 -3
  38. package/docs/testcafe.md +1 -1
  39. package/docs/translation.md +2 -2
  40. package/docs/videos.md +2 -2
  41. package/docs/visual.md +2 -2
  42. package/docs/vue.md +1 -1
  43. package/docs/webdriver.md +92 -4
  44. package/lib/actor.js +2 -2
  45. package/lib/cli.js +25 -20
  46. package/lib/command/init.js +5 -15
  47. package/lib/command/workers/runTests.js +25 -7
  48. package/lib/config.js +17 -13
  49. package/lib/helper/ApiDataFactory.js +13 -6
  50. package/lib/helper/Appium.js +65 -3
  51. package/lib/helper/FileSystem.js +11 -1
  52. package/lib/helper/GraphQL.js +11 -0
  53. package/lib/helper/JSONResponse.js +297 -0
  54. package/lib/helper/Playwright.js +215 -89
  55. package/lib/helper/Puppeteer.js +13 -4
  56. package/lib/helper/REST.js +36 -0
  57. package/lib/helper/WebDriver.js +1 -1
  58. package/lib/helper/extras/Console.js +8 -0
  59. package/lib/helper/extras/PlaywrightRestartOpts.js +35 -0
  60. package/lib/interfaces/bdd.js +3 -1
  61. package/lib/listener/timeout.js +4 -3
  62. package/lib/plugin/allure.js +12 -0
  63. package/lib/plugin/autoLogin.js +1 -1
  64. package/lib/plugin/eachElement.js +127 -0
  65. package/lib/plugin/retryFailedStep.js +4 -3
  66. package/lib/plugin/stepTimeout.js +5 -4
  67. package/lib/plugin/tryTo.js +6 -0
  68. package/lib/recorder.js +2 -1
  69. package/lib/step.js +57 -2
  70. package/lib/utils.js +20 -0
  71. package/package.json +6 -4
  72. package/translations/pt-BR.js +8 -0
  73. package/typings/index.d.ts +4 -0
  74. package/typings/types.d.ts +345 -110
@@ -18,7 +18,17 @@ Can be easily used to check file structures:
18
18
  I.amInPath('test');
19
19
  I.seeFile('codecept.json');
20
20
  I.seeInThisFile('FileSystem');
21
- I.dontSeeInThisFile("WebDriverIO");
21
+ I.dontSeeInThisFile("WebDriver");
22
+ ```
23
+
24
+ ## Configuration
25
+
26
+ Enable helper in config file:
27
+
28
+ ```js
29
+ helpers: {
30
+ FileSystem: {},
31
+ }
22
32
  ```
23
33
 
24
34
  ## Methods
@@ -0,0 +1,230 @@
1
+ ---
2
+ permalink: /helpers/JSONResponse
3
+ editLink: false
4
+ sidebar: auto
5
+ title: JSONResponse
6
+ ---
7
+
8
+ <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
9
+
10
+ ## JSONResponse
11
+
12
+ **Extends Helper**
13
+
14
+ This helper allows performing assertions on JSON responses paired with following helpers:
15
+
16
+ - REST
17
+ - GraphQL
18
+ - Playwright
19
+
20
+ It can check status codes, response data, response structure.
21
+
22
+ ## Configuration
23
+
24
+ - `requestHelper` - a helper which will perform requests. `REST` by default, also `Playwright` or `GraphQL` can be used. Custom helpers must have `onResponse` hook in their config, which will be executed when request is performed.
25
+
26
+ ### Examples
27
+
28
+ Zero-configuration when paired with REST:
29
+
30
+ ```js
31
+ // inside codecept.conf.js
32
+ {
33
+ helpers: {
34
+ REST: {
35
+ endpoint: 'http://site.com/api',
36
+ },
37
+ JSONResponse: {}
38
+ }
39
+ }
40
+ ```
41
+
42
+ Explicitly setting request helper if you use `makeApiRequest` of Playwright to perform requests and not paired REST:
43
+
44
+ ```js
45
+ // inside codecept.conf.js
46
+ // ...
47
+ helpers: {
48
+ Playwright: {
49
+ url: 'https://localhost',
50
+ browser: 'chromium',
51
+ },
52
+ JSONResponse: {
53
+ requestHelper: 'Playwright',
54
+ }
55
+ }
56
+ ```
57
+
58
+ ## Access From Helpers
59
+
60
+ If you plan to add custom assertions it is recommended to create a helper that will retrieve response object from JSONResponse:
61
+
62
+ ```js
63
+ // inside custom helper
64
+ const response = this.helpers.JSONResponse.response;
65
+ ```
66
+
67
+ ## Methods
68
+
69
+ ### Parameters
70
+
71
+ - `config`
72
+
73
+ ### dontSeeResponseCodeIs
74
+
75
+ Checks that response code is not equal to the provided one
76
+
77
+ ```js
78
+ I.dontSeeResponseCodeIs(500);
79
+ ```
80
+
81
+ #### Parameters
82
+
83
+ - `code` **[number][1]**
84
+
85
+ ### dontSeeResponseContainsJson
86
+
87
+ Checks for deep inclusion of a provided json in a response data.
88
+
89
+ ```js
90
+ // response.data == { data: { user: 1 } }
91
+
92
+ I.dontSeeResponseContainsJson({ user: 2 });
93
+ ```
94
+
95
+ #### Parameters
96
+
97
+ - `json` **[object][2]**
98
+
99
+ ### seeResponseCodeIs
100
+
101
+ Checks that response code is equal to the provided one
102
+
103
+ ```js
104
+ I.seeResponseCodeIs(200);
105
+ ```
106
+
107
+ #### Parameters
108
+
109
+ - `code` **[number][1]**
110
+
111
+ ### seeResponseCodeIsClientError
112
+
113
+ Checks that the response code is 4xx
114
+
115
+ ### seeResponseCodeIsRedirection
116
+
117
+ Checks that the response code is 3xx
118
+
119
+ ### seeResponseCodeIsServerError
120
+
121
+ Checks that the response code is 5xx
122
+
123
+ ### seeResponseCodeIsSuccessful
124
+
125
+ Checks that the response code is 2xx
126
+ Use it instead of seeResponseCodeIs(200) if server can return 204 instead.
127
+
128
+ ```js
129
+ I.seeResponseCodeIsSuccessful();
130
+ ```
131
+
132
+ ### seeResponseContainsJson
133
+
134
+ Checks for deep inclusion of a provided json in a response data.
135
+
136
+ ```js
137
+ // response.data == { user: { name: 'jon', email: 'jon@doe.com' } }
138
+
139
+ I.seeResponseContainsJson({ user: { email: 'jon@doe.com' } });
140
+ ```
141
+
142
+ #### Parameters
143
+
144
+ - `json` **[object][2]**
145
+
146
+ ### seeResponseContainsKeys
147
+
148
+ Checks for deep inclusion of a provided json in a response data.
149
+
150
+ ```js
151
+ // response.data == { user: { name: 'jon', email: 'jon@doe.com' } }
152
+
153
+ I.seeResponseContainsKeys(['user']);
154
+ ```
155
+
156
+ #### Parameters
157
+
158
+ - `keys` **[array][3]**
159
+
160
+ ### seeResponseEquals
161
+
162
+ Checks that response data equals to expected:
163
+
164
+ ```js
165
+ // response.data is { error: 'Not allowed' }
166
+
167
+ I.seeResponseEquals({ error: 'Not allowed' })
168
+ ```
169
+
170
+ #### Parameters
171
+
172
+ - `resp` **[object][2]**
173
+
174
+ ### seeResponseMatchesJsonSchema
175
+
176
+ Validates JSON structure of response using [joi library][4].
177
+ See [joi API][5] for complete reference on usage.
178
+
179
+ Use pre-initialized joi instance by passing function callback:
180
+
181
+ ```js
182
+ // response.data is { name: 'jon', id: 1 }
183
+
184
+ I.seeResponseMatchesJsonSchema(joi => {
185
+ return joi.object({
186
+ name: joi.string();
187
+ id: joi.number();
188
+ })
189
+ });
190
+
191
+ // or pass a valid schema
192
+ const joi = require('joi);
193
+
194
+ I.seeResponseMatchesJsonSchema(joi.object({
195
+ name: joi.string();
196
+ id: joi.number();
197
+ });
198
+ ```
199
+
200
+ #### Parameters
201
+
202
+ - `fnOrSchema` **any**
203
+
204
+ ### seeResponseValidByCallback
205
+
206
+ Executes a callback function passing in `response` object and chai assertions with `expect`
207
+ Use it to perform custom checks of response data
208
+
209
+ ```js
210
+ I.seeResponseValidByCallback({ data, status, expect } => {
211
+ expect(status).to.eql(200);
212
+ expect(data).keys.to.include(['user', 'company']);
213
+ });
214
+ ```
215
+
216
+ #### Parameters
217
+
218
+ - `fn` **[function][6]**
219
+
220
+ [1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
221
+
222
+ [2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
223
+
224
+ [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
225
+
226
+ [4]: https://joi.dev
227
+
228
+ [5]: https://joi.dev/api/
229
+
230
+ [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function