codeceptjs 4.0.0-rc.2 → 4.0.0-rc.20

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 (294) hide show
  1. package/README.md +39 -27
  2. package/bin/codecept.js +15 -2
  3. package/bin/codeceptq.js +49 -0
  4. package/bin/mcp-server.js +1187 -0
  5. package/docs/advanced.md +201 -0
  6. package/docs/agents.md +159 -0
  7. package/docs/ai.md +537 -0
  8. package/docs/aitrace.md +266 -0
  9. package/docs/api.md +332 -0
  10. package/docs/assertions.md +415 -0
  11. package/docs/auth.md +318 -0
  12. package/docs/basics.md +424 -0
  13. package/docs/bdd.md +539 -0
  14. package/docs/best.md +240 -0
  15. package/docs/bootstrap.md +132 -0
  16. package/docs/commands.md +352 -0
  17. package/docs/community-helpers.md +63 -0
  18. package/docs/configuration.md +230 -0
  19. package/docs/continuous-integration.md +497 -0
  20. package/docs/custom-helpers.md +297 -0
  21. package/docs/data.md +448 -0
  22. package/docs/debugging.md +332 -0
  23. package/docs/detox.md +235 -0
  24. package/docs/docker.md +136 -0
  25. package/docs/effects.md +179 -0
  26. package/docs/element-based-testing.md +295 -0
  27. package/docs/element-selection.md +125 -0
  28. package/docs/els.md +328 -0
  29. package/docs/examples.md +161 -0
  30. package/docs/heal.md +213 -0
  31. package/docs/helpers/ApiDataFactory.md +267 -0
  32. package/docs/helpers/Appium.md +1405 -0
  33. package/docs/helpers/Detox.md +665 -0
  34. package/docs/helpers/ExpectHelper.md +275 -0
  35. package/docs/helpers/FileSystem.md +152 -0
  36. package/docs/helpers/GraphQL.md +152 -0
  37. package/docs/helpers/GraphQLDataFactory.md +226 -0
  38. package/docs/helpers/JSONResponse.md +255 -0
  39. package/docs/helpers/Mochawesome.md +8 -0
  40. package/docs/helpers/MockRequest.md +377 -0
  41. package/docs/helpers/MockServer.md +212 -0
  42. package/docs/helpers/Playwright.md +2969 -0
  43. package/docs/helpers/Polly.md +44 -0
  44. package/docs/helpers/Protractor.md +1769 -0
  45. package/docs/helpers/Puppeteer-firefox.md +86 -0
  46. package/docs/helpers/Puppeteer.md +2690 -0
  47. package/docs/helpers/REST.md +289 -0
  48. package/docs/helpers/SoftExpectHelper.md +352 -0
  49. package/docs/helpers/WebDriver.md +2682 -0
  50. package/docs/hooks.md +339 -0
  51. package/docs/index.md +111 -0
  52. package/docs/installation.md +83 -0
  53. package/docs/internal-api.md +265 -0
  54. package/docs/internal-test-server.md +89 -0
  55. package/docs/locators.md +355 -0
  56. package/docs/mcp.md +485 -0
  57. package/docs/migration-4.md +556 -0
  58. package/docs/mobile.md +338 -0
  59. package/docs/pageobjects.md +399 -0
  60. package/docs/parallel.md +585 -0
  61. package/docs/playwright.md +714 -0
  62. package/docs/plugins.md +866 -0
  63. package/docs/puppeteer.md +314 -0
  64. package/docs/quickstart.md +120 -0
  65. package/docs/react.md +70 -0
  66. package/docs/reports.md +483 -0
  67. package/docs/retry.md +274 -0
  68. package/docs/secrets.md +150 -0
  69. package/docs/sessions.md +80 -0
  70. package/docs/shadow.md +68 -0
  71. package/docs/test-structure.md +275 -0
  72. package/docs/timeouts.md +183 -0
  73. package/docs/translation.md +247 -0
  74. package/docs/tutorial.md +271 -0
  75. package/docs/typescript.md +374 -0
  76. package/docs/web-element.md +251 -0
  77. package/docs/webdriver.md +708 -0
  78. package/docs/within.md +55 -0
  79. package/lib/ai.js +3 -2
  80. package/lib/aria.js +260 -0
  81. package/lib/assertions.js +18 -0
  82. package/lib/codecept.js +26 -23
  83. package/lib/command/check.js +2 -1
  84. package/lib/command/dryRun.js +24 -5
  85. package/lib/command/generate.js +2 -0
  86. package/lib/command/gherkin/snippets.js +5 -4
  87. package/lib/command/init.js +248 -269
  88. package/lib/command/list.js +150 -10
  89. package/lib/command/query.js +218 -0
  90. package/lib/command/run-multiple.js +2 -0
  91. package/lib/command/run-workers.js +2 -0
  92. package/lib/command/run.js +1 -1
  93. package/lib/command/workers/runTests.js +10 -10
  94. package/lib/config.js +77 -4
  95. package/lib/container.js +114 -17
  96. package/lib/effects.js +17 -0
  97. package/lib/element/WebElement.js +246 -2
  98. package/lib/els.js +12 -6
  99. package/lib/globals.js +32 -19
  100. package/lib/heal.js +4 -3
  101. package/lib/helper/ApiDataFactory.js +2 -1
  102. package/lib/helper/Appium.js +8 -8
  103. package/lib/helper/FileSystem.js +3 -2
  104. package/lib/helper/GraphQLDataFactory.js +2 -1
  105. package/lib/helper/Playwright.js +228 -162
  106. package/lib/helper/Puppeteer.js +208 -76
  107. package/lib/helper/WebDriver.js +173 -68
  108. package/lib/helper/errors/MultipleElementsFound.js +27 -110
  109. package/lib/helper/errors/NonFocusedType.js +8 -0
  110. package/lib/helper/extras/Download.js +45 -0
  111. package/lib/helper/extras/PlaywrightReactVueLocator.js +45 -36
  112. package/lib/helper/extras/elementSelection.js +58 -0
  113. package/lib/helper/extras/focusCheck.js +43 -0
  114. package/lib/helper/extras/richTextEditor.js +178 -0
  115. package/lib/helper/scripts/dropFile.js +11 -0
  116. package/lib/history.js +3 -2
  117. package/lib/html.js +103 -16
  118. package/lib/index.js +9 -1
  119. package/lib/listener/config.js +6 -4
  120. package/lib/listener/emptyRun.js +2 -1
  121. package/lib/listener/globalRetry.js +32 -6
  122. package/lib/listener/helpers.js +4 -1
  123. package/lib/listener/mocha.js +2 -1
  124. package/lib/listener/pageobjects.js +43 -0
  125. package/lib/listener/result.js +3 -2
  126. package/lib/locator.js +126 -3
  127. package/lib/mocha/cli.js +14 -2
  128. package/lib/mocha/factory.js +7 -2
  129. package/lib/mocha/inject.js +1 -1
  130. package/lib/mocha/scenarioConfig.js +2 -1
  131. package/lib/mocha/ui.js +5 -6
  132. package/lib/parser.js +2 -2
  133. package/lib/pause.js +38 -4
  134. package/lib/plugin/aiTrace.js +453 -0
  135. package/lib/plugin/analyze.js +1 -1
  136. package/lib/plugin/auth.js +3 -3
  137. package/lib/plugin/browser.js +77 -0
  138. package/lib/plugin/expose.js +159 -0
  139. package/lib/plugin/heal.js +44 -1
  140. package/lib/plugin/pageInfo.js +53 -49
  141. package/lib/plugin/pause.js +131 -0
  142. package/lib/plugin/pauseOnFail.js +10 -34
  143. package/lib/plugin/retryFailedStep.js +28 -19
  144. package/lib/plugin/screencast.js +287 -0
  145. package/lib/plugin/screenshot.js +563 -0
  146. package/lib/plugin/screenshotOnFail.js +8 -171
  147. package/lib/rerun.js +2 -1
  148. package/lib/result.js +2 -1
  149. package/lib/step/base.js +3 -2
  150. package/lib/step/config.js +15 -2
  151. package/lib/step/record.js +2 -2
  152. package/lib/store.js +72 -3
  153. package/lib/translation.js +2 -1
  154. package/lib/utils/mask_data.js +2 -1
  155. package/lib/utils/pluginParser.js +151 -0
  156. package/lib/utils/trace.js +297 -0
  157. package/lib/utils.js +77 -3
  158. package/lib/workers.js +52 -22
  159. package/package.json +19 -13
  160. package/typings/index.d.ts +19 -5
  161. package/docs/webapi/amOnPage.mustache +0 -11
  162. package/docs/webapi/appendField.mustache +0 -11
  163. package/docs/webapi/attachFile.mustache +0 -12
  164. package/docs/webapi/blur.mustache +0 -18
  165. package/docs/webapi/checkOption.mustache +0 -13
  166. package/docs/webapi/clearCookie.mustache +0 -9
  167. package/docs/webapi/clearField.mustache +0 -9
  168. package/docs/webapi/click.mustache +0 -29
  169. package/docs/webapi/clickLink.mustache +0 -8
  170. package/docs/webapi/closeCurrentTab.mustache +0 -7
  171. package/docs/webapi/closeOtherTabs.mustache +0 -8
  172. package/docs/webapi/dontSee.mustache +0 -11
  173. package/docs/webapi/dontSeeCheckboxIsChecked.mustache +0 -10
  174. package/docs/webapi/dontSeeCookie.mustache +0 -8
  175. package/docs/webapi/dontSeeCurrentPathEquals.mustache +0 -10
  176. package/docs/webapi/dontSeeCurrentUrlEquals.mustache +0 -10
  177. package/docs/webapi/dontSeeElement.mustache +0 -8
  178. package/docs/webapi/dontSeeElementInDOM.mustache +0 -8
  179. package/docs/webapi/dontSeeInCurrentUrl.mustache +0 -4
  180. package/docs/webapi/dontSeeInField.mustache +0 -11
  181. package/docs/webapi/dontSeeInSource.mustache +0 -8
  182. package/docs/webapi/dontSeeInTitle.mustache +0 -8
  183. package/docs/webapi/dontSeeTraffic.mustache +0 -13
  184. package/docs/webapi/doubleClick.mustache +0 -13
  185. package/docs/webapi/downloadFile.mustache +0 -12
  186. package/docs/webapi/dragAndDrop.mustache +0 -9
  187. package/docs/webapi/dragSlider.mustache +0 -11
  188. package/docs/webapi/executeAsyncScript.mustache +0 -24
  189. package/docs/webapi/executeScript.mustache +0 -26
  190. package/docs/webapi/fillField.mustache +0 -16
  191. package/docs/webapi/flushNetworkTraffics.mustache +0 -5
  192. package/docs/webapi/focus.mustache +0 -13
  193. package/docs/webapi/forceClick.mustache +0 -28
  194. package/docs/webapi/forceRightClick.mustache +0 -18
  195. package/docs/webapi/grabAllWindowHandles.mustache +0 -7
  196. package/docs/webapi/grabAttributeFrom.mustache +0 -10
  197. package/docs/webapi/grabAttributeFromAll.mustache +0 -9
  198. package/docs/webapi/grabBrowserLogs.mustache +0 -9
  199. package/docs/webapi/grabCookie.mustache +0 -11
  200. package/docs/webapi/grabCssPropertyFrom.mustache +0 -11
  201. package/docs/webapi/grabCssPropertyFromAll.mustache +0 -10
  202. package/docs/webapi/grabCurrentUrl.mustache +0 -9
  203. package/docs/webapi/grabCurrentWindowHandle.mustache +0 -6
  204. package/docs/webapi/grabDataFromPerformanceTiming.mustache +0 -20
  205. package/docs/webapi/grabElementBoundingRect.mustache +0 -20
  206. package/docs/webapi/grabGeoLocation.mustache +0 -8
  207. package/docs/webapi/grabHTMLFrom.mustache +0 -10
  208. package/docs/webapi/grabHTMLFromAll.mustache +0 -9
  209. package/docs/webapi/grabNumberOfOpenTabs.mustache +0 -8
  210. package/docs/webapi/grabNumberOfVisibleElements.mustache +0 -9
  211. package/docs/webapi/grabPageScrollPosition.mustache +0 -8
  212. package/docs/webapi/grabPopupText.mustache +0 -5
  213. package/docs/webapi/grabRecordedNetworkTraffics.mustache +0 -10
  214. package/docs/webapi/grabSource.mustache +0 -8
  215. package/docs/webapi/grabTextFrom.mustache +0 -10
  216. package/docs/webapi/grabTextFromAll.mustache +0 -9
  217. package/docs/webapi/grabTitle.mustache +0 -8
  218. package/docs/webapi/grabValueFrom.mustache +0 -9
  219. package/docs/webapi/grabValueFromAll.mustache +0 -8
  220. package/docs/webapi/grabWebElement.mustache +0 -9
  221. package/docs/webapi/grabWebElements.mustache +0 -9
  222. package/docs/webapi/moveCursorTo.mustache +0 -12
  223. package/docs/webapi/openNewTab.mustache +0 -7
  224. package/docs/webapi/pressKey.mustache +0 -12
  225. package/docs/webapi/pressKeyDown.mustache +0 -12
  226. package/docs/webapi/pressKeyUp.mustache +0 -12
  227. package/docs/webapi/pressKeyWithKeyNormalization.mustache +0 -60
  228. package/docs/webapi/refreshPage.mustache +0 -6
  229. package/docs/webapi/resizeWindow.mustache +0 -6
  230. package/docs/webapi/rightClick.mustache +0 -14
  231. package/docs/webapi/saveElementScreenshot.mustache +0 -10
  232. package/docs/webapi/saveScreenshot.mustache +0 -12
  233. package/docs/webapi/say.mustache +0 -10
  234. package/docs/webapi/scrollIntoView.mustache +0 -11
  235. package/docs/webapi/scrollPageToBottom.mustache +0 -6
  236. package/docs/webapi/scrollPageToTop.mustache +0 -6
  237. package/docs/webapi/scrollTo.mustache +0 -12
  238. package/docs/webapi/see.mustache +0 -11
  239. package/docs/webapi/seeAttributesOnElements.mustache +0 -9
  240. package/docs/webapi/seeCheckboxIsChecked.mustache +0 -10
  241. package/docs/webapi/seeCookie.mustache +0 -8
  242. package/docs/webapi/seeCssPropertiesOnElements.mustache +0 -9
  243. package/docs/webapi/seeCurrentPathEquals.mustache +0 -10
  244. package/docs/webapi/seeCurrentUrlEquals.mustache +0 -11
  245. package/docs/webapi/seeElement.mustache +0 -8
  246. package/docs/webapi/seeElementInDOM.mustache +0 -8
  247. package/docs/webapi/seeInCurrentUrl.mustache +0 -8
  248. package/docs/webapi/seeInField.mustache +0 -12
  249. package/docs/webapi/seeInPopup.mustache +0 -8
  250. package/docs/webapi/seeInSource.mustache +0 -7
  251. package/docs/webapi/seeInTitle.mustache +0 -8
  252. package/docs/webapi/seeNumberOfElements.mustache +0 -11
  253. package/docs/webapi/seeNumberOfVisibleElements.mustache +0 -10
  254. package/docs/webapi/seeTextEquals.mustache +0 -9
  255. package/docs/webapi/seeTitleEquals.mustache +0 -8
  256. package/docs/webapi/seeTraffic.mustache +0 -36
  257. package/docs/webapi/selectOption.mustache +0 -21
  258. package/docs/webapi/setCookie.mustache +0 -16
  259. package/docs/webapi/setGeoLocation.mustache +0 -12
  260. package/docs/webapi/startRecordingTraffic.mustache +0 -8
  261. package/docs/webapi/startRecordingWebSocketMessages.mustache +0 -8
  262. package/docs/webapi/stopRecordingTraffic.mustache +0 -5
  263. package/docs/webapi/stopRecordingWebSocketMessages.mustache +0 -7
  264. package/docs/webapi/switchTo.mustache +0 -9
  265. package/docs/webapi/switchToNextTab.mustache +0 -10
  266. package/docs/webapi/switchToPreviousTab.mustache +0 -10
  267. package/docs/webapi/type.mustache +0 -21
  268. package/docs/webapi/uncheckOption.mustache +0 -13
  269. package/docs/webapi/wait.mustache +0 -8
  270. package/docs/webapi/waitForClickable.mustache +0 -11
  271. package/docs/webapi/waitForCookie.mustache +0 -9
  272. package/docs/webapi/waitForDetached.mustache +0 -10
  273. package/docs/webapi/waitForDisabled.mustache +0 -6
  274. package/docs/webapi/waitForElement.mustache +0 -11
  275. package/docs/webapi/waitForEnabled.mustache +0 -6
  276. package/docs/webapi/waitForFunction.mustache +0 -17
  277. package/docs/webapi/waitForInvisible.mustache +0 -10
  278. package/docs/webapi/waitForNumberOfTabs.mustache +0 -9
  279. package/docs/webapi/waitForText.mustache +0 -13
  280. package/docs/webapi/waitForValue.mustache +0 -10
  281. package/docs/webapi/waitForVisible.mustache +0 -10
  282. package/docs/webapi/waitInUrl.mustache +0 -9
  283. package/docs/webapi/waitNumberOfVisibleElements.mustache +0 -10
  284. package/docs/webapi/waitToHide.mustache +0 -10
  285. package/docs/webapi/waitUrlEquals.mustache +0 -10
  286. package/lib/helper/AI.js +0 -214
  287. package/lib/listener/enhancedGlobalRetry.js +0 -110
  288. package/lib/plugin/enhancedRetryFailedStep.js +0 -99
  289. package/lib/plugin/htmlReporter.js +0 -3648
  290. package/lib/plugin/stepByStepReport.js +0 -427
  291. package/lib/plugin/subtitles.js +0 -89
  292. package/lib/retryCoordinator.js +0 -207
  293. package/typings/promiseBasedTypes.d.ts +0 -9469
  294. package/typings/types.d.ts +0 -11402
@@ -0,0 +1,332 @@
1
+ ---
2
+ permalink: /debugging
3
+ title: Debugging Tests
4
+ ---
5
+
6
+ # Debugging Tests
7
+
8
+ CodeceptJS provides powerful tools for debugging your tests at every level: from verbose output to interactive breakpoints with step-by-step execution.
9
+
10
+ ## Output Verbosity
11
+
12
+ When something goes wrong, start by increasing the output level:
13
+
14
+ ```bash
15
+ npx codeceptjs run --steps # print each step
16
+ npx codeceptjs run --debug # print steps + debug info
17
+ npx codeceptjs run --verbose # print everything
18
+ ```
19
+
20
+ | Flag | What you see |
21
+ |------|-------------|
22
+ | `--steps` | Each executed step (`I click`, `I see`, etc.) |
23
+ | `--debug` | Steps + helper/plugin info, URLs, loaded config |
24
+ | `--verbose` | Everything above + internal promise queue, retries, timeouts |
25
+
26
+ We recommend **always using `--debug`** when developing tests.
27
+
28
+ For full internal logs, use the `DEBUG` environment variable:
29
+
30
+ ```bash
31
+ DEBUG=codeceptjs:* npx codeceptjs run
32
+ ```
33
+
34
+ You can narrow it down to specific modules:
35
+
36
+ ```bash
37
+ DEBUG=codeceptjs:recorder npx codeceptjs run # promise chain only
38
+ DEBUG=codeceptjs:pause npx codeceptjs run # pause session only
39
+ ```
40
+
41
+ ## Interactive Pause
42
+
43
+ The most powerful debugging tool in CodeceptJS is **interactive pause**. It stops test execution and opens a live shell where you can run steps directly in the browser.
44
+
45
+ Add `pause()` anywhere in your test:
46
+
47
+ ```js
48
+ Scenario('debug checkout', ({ I }) => {
49
+ I.amOnPage('/products')
50
+ I.click('Add to Cart')
51
+ pause() // <-- test stops here, shell opens
52
+ I.click('Checkout')
53
+ })
54
+ ```
55
+
56
+ When the shell opens, you'll see:
57
+
58
+ ```
59
+ Interactive shell started
60
+ Use JavaScript syntax to try steps in action
61
+ - Press ENTER to run the next step
62
+ - Press TAB twice to see all available commands
63
+ - Type exit + Enter to exit the interactive shell
64
+ - Prefix => to run js commands
65
+ ```
66
+
67
+ ### Available Commands
68
+
69
+ | Input | What it does |
70
+ |-------|-------------|
71
+ | `click('Login')` | Runs `I.click('Login')` — the `I.` prefix is added automatically |
72
+ | `see('Welcome')` | Runs `I.see('Welcome')` |
73
+ | `grabCurrentUrl()` | Runs a grab method and prints the result |
74
+ | `=> myVar` | Evaluates JavaScript expression |
75
+ | *ENTER* (empty) | Runs the next test step and pauses again |
76
+ | `exit` or `resume` | Exits the shell and continues the test |
77
+ | *TAB TAB* | Shows all available I.* methods |
78
+
79
+ You can also pass variables into the shell:
80
+
81
+ ```js
82
+ const userData = { name: 'John', email: 'john@test.com' }
83
+ pause({ userData })
84
+ // in shell: => userData.name
85
+ ```
86
+
87
+ ### Using Pause as a Stop Point
88
+
89
+ `pause()` works as a **breakpoint** in your test. Place it before a failing step to inspect the page state:
90
+
91
+ ```js
92
+ Scenario('fix login bug', ({ I }) => {
93
+ I.amOnPage('/login')
94
+ I.fillField('Email', 'user@test.com')
95
+ I.fillField('Password', 'secret')
96
+ pause() // stop here, inspect the form before submitting
97
+ I.click('Sign In')
98
+ I.see('Dashboard')
99
+ })
100
+ ```
101
+
102
+ You can also add it in hooks:
103
+
104
+ ```js
105
+ After(({ I }) => {
106
+ pause() // pause after every test to inspect final state
107
+ })
108
+ ```
109
+
110
+ ### Pause Modes
111
+
112
+ `pause()` adapts to who's driving the test:
113
+
114
+ - **TTY (humans)** — when `process.stdin` is a terminal (running `npx codeceptjs run --debug` yourself), the readline REPL described above opens.
115
+ - **MCP server (agent-driven debug)** — the MCP server registers an in-process pause handler before running tests, so when `pause()` fires inside a `run_test` invocation, control yields back to the agent. The agent drives the REPL through the [`pause` MCP tool](/mcp#pause). The same `I` container the test uses runs the agent's code, so artifacts (URL, ARIA, HTML, screenshot, console, storage) are captured against the live page.
116
+
117
+ ## Pause Plugin
118
+
119
+ For automated debugging without modifying test code, use the `pause` plugin. It pauses tests based on different triggers, controlled entirely from the command line. The default is `on=fail`.
120
+
121
+ ### Pause on Failure
122
+
123
+ Automatically enters interactive pause when a step fails:
124
+
125
+ ```bash
126
+ npx codeceptjs run -p pause
127
+ # or, explicit:
128
+ npx codeceptjs run -p pause:on=fail
129
+ ```
130
+
131
+ This is the most common debug workflow — run your tests, and when one fails, you land in the interactive shell with the browser in the exact state of the failure. You can inspect elements, try different selectors, and figure out what went wrong.
132
+
133
+ > The legacy `pauseOnFail` plugin still works as a deprecated alias.
134
+
135
+ ### Pause on Every Step
136
+
137
+ Enters interactive pause at the start of the test. Use *ENTER* to advance step by step:
138
+
139
+ ```bash
140
+ npx codeceptjs run -p pause:on=step
141
+ ```
142
+
143
+ This gives you full step-by-step execution. After each step, you're back in the interactive shell where you can inspect the page before pressing ENTER to continue.
144
+
145
+ ### Pause on File (Breakpoint)
146
+
147
+ Pauses when execution reaches a specific file:
148
+
149
+ ```bash
150
+ npx codeceptjs run -p pause:on=file:path=tests/login_test.js
151
+ ```
152
+
153
+ With a specific line number:
154
+
155
+ ```bash
156
+ npx codeceptjs run -p pause:on=file:path=tests/login_test.js;line=43
157
+ ```
158
+
159
+ This works like a breakpoint — the test runs normally until it hits a step defined at that file and line, then opens the interactive shell.
160
+
161
+ ### Pause on URL
162
+
163
+ Pauses when the browser navigates to a matching URL:
164
+
165
+ ```bash
166
+ npx codeceptjs run -p pause:on=url:pattern=/users/1
167
+ ```
168
+
169
+ Supports `*` wildcards:
170
+
171
+ ```bash
172
+ npx codeceptjs run -p pause:on=url:pattern=/api/*/edit
173
+ npx codeceptjs run -p pause:on=url:pattern=/checkout/*
174
+ ```
175
+
176
+ This is useful when you want to inspect a specific page regardless of which test step navigates there.
177
+
178
+ ## Browser Control
179
+
180
+ For ad-hoc overrides of browser helper config without editing `codecept.conf`, use the `browser` plugin via `-p`. Works for Playwright, Puppeteer, WebDriver and Appium in one call.
181
+
182
+ Force a visible browser:
183
+
184
+ ```bash
185
+ npx codeceptjs run -p browser:show
186
+ ```
187
+
188
+ Force headless (also injects `--headless` into WebDriver chrome/firefox capability args):
189
+
190
+ ```bash
191
+ npx codeceptjs run -p browser:hide
192
+ ```
193
+
194
+ Switch the browser engine for Playwright / Puppeteer / WebDriver / TestCafe in one shot — no per-helper config gymnastics:
195
+
196
+ ```bash
197
+ npx codeceptjs run -p browser:browser=firefox
198
+ npx codeceptjs run -p browser:browser=webkit:hide
199
+ ```
200
+
201
+ Pass any other helper config as `key=value`. Values are coerced (`true`/`false` → boolean, digits → Number, otherwise string). Tokens are colon-chained on a single `-p`:
202
+
203
+ ```bash
204
+ npx codeceptjs run -p browser:windowSize=1024x768:video=false
205
+ npx codeceptjs run -p browser:hide:video=true
206
+ ```
207
+
208
+ `browser=<name>` routes through `setBrowser` (so Puppeteer correctly receives `product`, Playwright receives `browser`, etc.); `windowSize=WxH` routes through `setWindowSize` (which also injects `--window-size=W,H` into chromium/chrome args). Anything else is shallow-merged onto every browser helper present in config.
209
+
210
+ ## IDE Debugging
211
+
212
+ ### VS Code
213
+
214
+ You can use the built-in Node.js debugger in VS Code to set breakpoints in test files.
215
+
216
+ Add this configuration to `.vscode/launch.json`:
217
+
218
+ ```json
219
+ {
220
+ "type": "node",
221
+ "request": "launch",
222
+ "name": "codeceptjs",
223
+ "args": ["run", "--grep", "@your_test_tag", "--debug"],
224
+ "program": "${workspaceFolder}/node_modules/codeceptjs/bin/codecept.js"
225
+ }
226
+ ```
227
+
228
+ Set breakpoints in your test files, then press F5 to start debugging. You'll be able to step through code, inspect variables, and use the VS Code debug console — all while the browser is open and controlled by the test.
229
+
230
+ Combine with `pause()` for the best experience: set a VS Code breakpoint to inspect JavaScript state, then add `pause()` to interact with the browser.
231
+
232
+ ### WebStorm
233
+
234
+ ```bash
235
+ node $NODE_DEBUG_OPTION ./node_modules/.bin/codeceptjs run
236
+ ```
237
+
238
+ ### Node.js Inspector
239
+
240
+ ```bash
241
+ node --inspect ./node_modules/.bin/codeceptjs run
242
+ node --inspect-brk ./node_modules/.bin/codeceptjs run # break on first line
243
+ ```
244
+
245
+ ## Debugging on Failure
246
+
247
+ Several built-in plugins capture information when tests fail. These are most useful on CI where you can't use interactive debugging.
248
+
249
+ ### Screenshots on Failure
250
+
251
+ Enabled by default. Saves a screenshot when a test fails:
252
+
253
+ ```js
254
+ plugins: {
255
+ screenshot: {
256
+ enabled: true,
257
+ on: 'fail',
258
+ uniqueScreenshotNames: true,
259
+ fullPageScreenshots: true,
260
+ }
261
+ }
262
+ ```
263
+
264
+ Screenshots are saved in the `output` directory. The same plugin also supports `on=test`, `on=step`, `on=file`, and `on=url` to capture screenshots in other situations.
265
+
266
+ ### Page Info on Failure
267
+
268
+ Captures URL, HTML errors, and browser console logs on failure:
269
+
270
+ ```js
271
+ plugins: {
272
+ pageInfo: {
273
+ enabled: true,
274
+ }
275
+ }
276
+ ```
277
+
278
+ ### Step-by-Step Report
279
+
280
+ Generates a slideshow of screenshots taken after every step — a visual replay of what the test did. Set `slides: true` on the `screenshot` plugin (with `on=step`):
281
+
282
+ ```js
283
+ plugins: {
284
+ screenshot: {
285
+ enabled: true,
286
+ on: 'step',
287
+ slides: true,
288
+ deleteSuccessful: true, // keep only failed tests
289
+ fullPageScreenshots: true,
290
+ }
291
+ }
292
+ ```
293
+
294
+ ```bash
295
+ npx codeceptjs run -p screenshot:on=step;slides=true
296
+ ```
297
+
298
+ After the run, open `output/records.html` to browse through the slideshows.
299
+
300
+ ## AI-Powered Debugging
301
+
302
+ ### AI in Interactive Pause
303
+
304
+ When AI is configured, the interactive pause shell accepts natural language commands:
305
+
306
+ ```
307
+ AI is enabled! (experimental) Write what you want and make AI run it
308
+
309
+ I.$ fill the login form with test credentials and submit
310
+ ```
311
+
312
+ AI reads the current page HTML and generates CodeceptJS steps. See [Testing with AI](/ai) for setup.
313
+
314
+ ### AI Trace Plugin
315
+
316
+ The `aiTrace` plugin captures rich execution traces for AI analysis — screenshots, HTML snapshots, ARIA trees, browser logs, and network requests at every step:
317
+
318
+ ```js
319
+ plugins: {
320
+ aiTrace: {
321
+ enabled: true,
322
+ }
323
+ }
324
+ ```
325
+
326
+ After a test run, trace files are generated in `output/trace_*/trace.md`. Feed these to an AI assistant (like Claude Code) for automated failure analysis. See [AI Trace Plugin](/aitrace) for details.
327
+
328
+ ### MCP Server
329
+
330
+ CodeceptJS includes an [MCP server](/mcp) that allows AI agents to control tests programmatically — list tests, run them step by step, capture artifacts, and analyze results. This enables AI-driven debugging workflows where an agent can investigate failures autonomously.
331
+
332
+ > AI agent integration and MCP server will be covered in detail on a dedicated page.
package/docs/detox.md ADDED
@@ -0,0 +1,235 @@
1
+ ---
2
+ permalink: /detox
3
+ title: Testing React Native with Detox
4
+ ---
5
+
6
+ > Warning! Detox support in CodeceptJS is experimental. Please try it and help us to test it and improve it. [See Detox helper repository](https://github.com/codeceptjs/detox-helper).
7
+
8
+ Automated mobile testing can be slow, hard, and ineffective. The price of it goes high, if we take into account fragility of applications, slowness of emulators, and the complexity of debug. [Appium](/mobile) helps writing mobile tests but not all apps can be tested effectively with it. That's why you should consider using an alternative approach.
9
+
10
+ Meet [Detox](https://github.com/wix/Detox) - grey-box testing solution for mobile testing by Wix.
11
+
12
+ Unlike, Appium, Detox requires to update mobile application to include test instrumentation, so an application could receive commands from a test, and act accordingly. Let's see pros and cons of such approach:
13
+
14
+
15
+ **Pros**:
16
+
17
+ * faster tests
18
+ * synchronization with application
19
+ * plays nicely with React Native
20
+
21
+ **Cons**:
22
+
23
+ * application should be built in a special way
24
+ * no hybrid applications
25
+ * native Android apps not supported (except React Native)
26
+ * no cloud testing with SauceLabs or BrowserStack
27
+
28
+ CodeceptJS allows you to try different options and choose the one which works best for you. Both Appium and Detox helpers share the same syntax for testing mobile applications, interactive pause, automatic retries, and other useful features.
29
+
30
+ CodeceptJS provides next features over standard Detox:
31
+
32
+ * **Unified API**. The same test can be executed in Appium or Detox. Unified API helps different teams to use the same syntax and easy port tests from one engine to another.
33
+ * [Interactive pause](/basics#pause). When starting/stopping an application takes a long time, debugging and writing tests can be hard. CodeceptJS solves this by pausing an execution and letting you try different commands and locators. With this feature a test can be writtern during one running session.
34
+ * [Auto-retries](/basics#retries) using `retryFailedStepPlugin` and `I.retry()`
35
+ * **Cross-Platform testing** - one test can be executed on different engines. When needed, platform-specific actions and locators can be easily applied.
36
+
37
+ ## A Test
38
+
39
+ Compare a test written for Detox using its native syntax:
40
+
41
+ ```js
42
+ await expect(element(by.text('Welcome'))).toBeVisible();
43
+ await expect(element(by.id('createdAndVisibleText'))).toNotExist();
44
+ await element(by.id('GoButton')).tap();
45
+ await waitFor(element(by.id('createdAndVisibleText'))).toExist().withTimeout(20000);
46
+ await expect(element(by.id('createdAndVisibleText'))).toExist();
47
+ ```
48
+
49
+ with the same test written using CodeceptJS syntax:
50
+
51
+ ```js
52
+ I.see('Welcome');
53
+ I.dontSeeElement('#createdAndVisibleText');
54
+ I.click('#GoButton');
55
+ I.waitForElement('#createdAndVisibleText', 20);
56
+ I.seeElement('#createdAndVisibleText');
57
+ ```
58
+
59
+ As you see, CodeceptJS test is shorter and easier to follow. By simplifying the code and reducing visual noise we make tests easier to follow. But before writing a test we need to prepare an application to be testable with Detox.
60
+
61
+ ## Setup
62
+
63
+ It is important to follow [Detox guide](https://github.com/wix/Detox/blob/master/docs/Introduction.GettingStarted.md) to build an application with Detox test instrouments included.
64
+
65
+ After you install Detox, create configuration and build an application using `detox build` command, you are ready to integrate Detox with CodeceptJS.
66
+
67
+ You need to install Detox CodeceptJS helper:
68
+
69
+ ```
70
+ npm i @codeceptjs/detox-helper --save-dev
71
+ ```
72
+
73
+ Then enable this helper in `codecept.conf.js`:
74
+
75
+ ```js
76
+ helpers: {
77
+ Detox: {
78
+ require: '@codeceptjs/detox-helper',
79
+ configuration: '<detox app configuration name>',
80
+ reloadReactNative: true,
81
+ }
82
+ }
83
+ ```
84
+
85
+ Enable `reloadReactNative: true` if you test React Native application.
86
+
87
+ ## Actions
88
+
89
+ Create test as usual, by running command:
90
+
91
+ ```
92
+ npx codeceptjs gt
93
+ ```
94
+
95
+ A test starts when emulator starts and loads an application. So you can begin testing an application.
96
+
97
+ ```js
98
+ // inside a created test
99
+ Scenario('test React Native app', ({ I }) => {
100
+ I.see('Welcome');
101
+ I.tap('Start');
102
+ I.see('Started!');
103
+ });
104
+ ```
105
+
106
+ The most common actions are:
107
+
108
+ * `tap` (or `click`)
109
+ * `multiTap` - perform multiple taps on element
110
+ * `longPress` - longer press
111
+ * `fillField` - fill in value of text field
112
+ * `clearField` - clear value in text field
113
+ * `appendField` - append value in a field
114
+ * `swipeUp`, `swipeDown`, `swipeLeft`, `swipeRigth`
115
+
116
+ There are also common assertions:
117
+
118
+ * `see` - to check visibility of text
119
+ * `seeElement` - to check visibility of element
120
+ * `seeElementExists` - to check that element exists
121
+
122
+ > For more details on actions refer to the [API reference of Detox helper](https://github.com/codeceptjs/detox-helper#api).
123
+
124
+ ## Locators
125
+
126
+ To write a test you need to learn about available locators in Detox.
127
+ Unlike, Appium there are no XPath locators. Possible locators limited to `text`, `id`, `accessibility id`, and element `type`. Thus, again, an application should be prepared for testing, to ensure that all active elements are accessible.
128
+
129
+ Let's see how they can be used:
130
+
131
+ * For **ID locators** use `#` prefix (same as in CSS). Example:
132
+
133
+ ```js
134
+ I.seeElement('#WelcomeScreen')
135
+ ```
136
+ * For **accessibility ID** use `~` prefix (as in Appium helper). Example:
137
+
138
+ ```js
139
+ I.seeElement('~welcome')
140
+ ```
141
+
142
+ * Locating elements **by text** requires no prefix, but can be applied only for actions accepting semantic locators.
143
+
144
+ ```js
145
+ I.tap('Start')
146
+ I.fillField('Username', 'davert')
147
+ I.clearField('Username')
148
+ I.see('Welcome, davert')
149
+ ```
150
+
151
+ * Locating elements **by type** also use no prefix but can be used only where for elements.
152
+
153
+ ```js
154
+ I.seeElement('Button')
155
+ ```
156
+
157
+ Text locators can be combined with others, as methods `tap`, `click` and `see` can receive a second paramater, which defines a context where to perfrom a search.
158
+
159
+ ```js
160
+ // tap "Start" inside "#Layout"
161
+ I.tap('Start', '#Layout');
162
+ // see text "Welcome" inside "~msg"
163
+ I.see('Welcome', '~msg');
164
+ ```
165
+
166
+ Alternatively, you can use specify locator by using *strict locator*, passing an object as a locator:
167
+
168
+ ```js
169
+ I.click({ type: 'Button' });
170
+ I.seeElement({ label: 'welcome' });
171
+ ```
172
+
173
+ > If you are familiar with Detox API, this is how locators are actually translated: `{label: 'welcome'}` => `by.label('welcome')`.
174
+
175
+ ### Cross Platform Testing
176
+
177
+ If element differs on on iOS and Android you can use **cross platform locators**.
178
+
179
+ ```js
180
+ // locate element by text on Android
181
+ // locate element by accessibility id on iOS
182
+ I.click({ android: 'Start', ios: '~start' });
183
+ ```
184
+
185
+ When application behavior differs on Android and iOS use platform-specific actions:
186
+
187
+ ```js
188
+ I.runOnIOS(() => {
189
+ // this will be executed only on IOS
190
+ I.see('Hello iOS');
191
+ });
192
+ I.runOnAndroid(() => {
193
+ // this will be executed only on Android
194
+ I.see('Hello Android');
195
+ });
196
+ ```
197
+
198
+ ### Sample Test
199
+
200
+ Finally, you can get a test looking like this
201
+
202
+ ```js
203
+ Feature('My Detox App');
204
+
205
+ Scenario('save in application', ({ I }) => {
206
+ I.setLandscapeOrientation();
207
+ I.fillField('#text', 'a new text');
208
+ I.see('a new text', '#textValue');
209
+ I.dontSeeElement('#createdAndVisibleText');
210
+ I.click({ ios: '#GoButton', android: 'Button' });
211
+ I.waitForElement('#createdAndVisibleText', 20);
212
+ I.seeElement('#createdAndVisibleText');
213
+ I.runOnAndroid(() => {
214
+ I.click('Save');
215
+ I.see('Text Saved', '#message');
216
+ });
217
+ I.runOnIOS(() => {
218
+ I.click('SAVE');
219
+ I.see('SAVED!');
220
+ });
221
+ });
222
+ ```
223
+
224
+ To execute it use `codeceptjs run` command
225
+
226
+ ```
227
+ npx codeceptjs run
228
+ ```
229
+ If you want to use detox configuration other than is set in `codecept.conf.js` use `--configuration` argument:
230
+
231
+ ```
232
+ npx codeceptjs run --configuration android.test.ci
233
+ ```
234
+
235
+ You can also pass all [other arguments that Detox CLI supports](https://github.com/wix/Detox/blob/master/docs/APIRef.DetoxCLI.md#test).
package/docs/docker.md ADDED
@@ -0,0 +1,136 @@
1
+ # Codeceptjs Docker
2
+
3
+ CodeceptJS has an [official docker image](https://hub.docker.com/r/codeceptjs/codeceptjs) based on Playwright image. Image supports Playwright, Puppeteer, and WebDriver engines.
4
+
5
+ ## How to Use
6
+
7
+ This image comes with the necessary dependencies and packages to execute CodeceptJS tests.
8
+ Mount in your CodeceptJS config directory into the `/tests` directory in the docker container.
9
+
10
+ Sample mount: `-v path/to/codecept.conf.js:/tests`
11
+
12
+ CodeceptJS runner is available inside container as `codeceptjs`.
13
+
14
+ ### Locally
15
+
16
+ You can execute CodeceptJS with Puppeteer locally with no extra configuration.
17
+
18
+ ```sh
19
+ docker run --net=host -v $PWD:/tests codeceptjs/codeceptjs
20
+ ```
21
+
22
+ To customize execution call `codeceptjs` command:
23
+
24
+ ```sh
25
+ # run tests with steps
26
+ docker run --net=host -v $PWD:/tests codeceptjs/codeceptjs codeceptjs run --steps
27
+
28
+ # run tests with @user in a name
29
+ docker run --net=host -v $PWD:/tests codeceptjs/codeceptjs codeceptjs run --grep "@user"
30
+ ```
31
+
32
+
33
+ ### Docker Compose
34
+
35
+ ```yaml
36
+ version: '2'
37
+ services:
38
+ codeceptjs:
39
+ image: codeceptjs/codeceptjs
40
+ depends_on:
41
+ - firefox
42
+ - web
43
+ volumes:
44
+ - .:/tests
45
+ web:
46
+ image: node
47
+ command: node app/server.js
48
+ volumes:
49
+ - .:/app
50
+ firefox:
51
+ image: selenium/standalone-firefox-debug:2.53.0
52
+ ports:
53
+ - '4444'
54
+ - '5900'
55
+ ```
56
+
57
+ ### Linking Containers
58
+
59
+ If using the WebDriver driver, link the container with a Selenium Standalone docker container with an alias of `selenium`. Additionally, make sure your `codeceptjs.conf.js` contains the following to allow CodeceptJS to identify where Selenium is running.
60
+
61
+ ```javascript
62
+ ...
63
+ helpers: {
64
+ WebDriver: {
65
+ ...
66
+ host: process.env.HOST
67
+ ...
68
+ }
69
+ }
70
+ ...
71
+ ```
72
+
73
+ ```sh
74
+ $ docker run -d -P --name selenium-chrome selenium/standalone-chrome
75
+
76
+ # Alternatively, selenium/standalone-firefox can be used
77
+
78
+ $ docker run -it --rm -v /<path_to_codeceptjs_test_dir>/:/tests/ --link selenium-chrome:selenium codeceptjs/codeceptjs
79
+ ```
80
+
81
+ You may run use `-v $(pwd)/:tests/` if running this from the root of your CodeceptJS tests directory.
82
+ _Note: The output of your test run will appear in your local directory if your output path is `./output` in the CodeceptJS config_
83
+
84
+ ### Build
85
+
86
+ To build this image:
87
+
88
+ ```sh
89
+ docker build -t codeceptjs/codeceptjs .
90
+ ```
91
+
92
+ * this directory will be added as `/codecept` insde container
93
+ * tests directory is expected to be mounted as `/tests`
94
+ * `codeceptjs` is a synlink to `/codecept/bin/codecept.js`
95
+
96
+ To build this image with your desired Node version:
97
+
98
+ ```sh
99
+ docker build -t codeceptjs/codeceptjs . --build-arg NODE_VERSION=12.10.0
100
+ ```
101
+
102
+ ### Passing Options
103
+
104
+ Options can be passed by calling `codeceptjs`:
105
+
106
+ ```
107
+ docker run -v $PWD:/tests codeceptjs/codeceptjs codeceptjs run --debug
108
+ ```
109
+
110
+ Alternatively arguments to `codecept run` command can be passed via `CODECEPT_ARGS` environment variable. For example to run your tests with debug
111
+ output:
112
+
113
+ ```yaml
114
+ version: '2'
115
+ services:
116
+ codeceptjs:
117
+ image: codeceptjs/codeceptjs
118
+ environment:
119
+ - CODECEPT_ARGS=--debug
120
+ volumes:
121
+ - .:/tests
122
+ ```
123
+
124
+ You can also use `run-workers`to run tests by passing `NO_OF_WORKERS`, additionally, you can pass more params like showing the debug info as the following example:
125
+
126
+ ```yaml
127
+ version: '2'
128
+ services:
129
+ codeceptjs:
130
+ image: codeceptjs/codeceptjs
131
+ environment:
132
+ - NO_OF_WORKERS=3
133
+ - CODECEPT_ARGS=--debug
134
+ volumes:
135
+ - .:/tests
136
+ ```