Commit fb28db2
Fix/refactor autoexit (#5556)
* update docs
* updated docs, added browser plugin
* fix(mcp): kill zombie Mocha state when timeout fires before test reaches pause()
When run_test's timeout was shorter than the time the test needed to
reach pause() (e.g. 50ms timeout vs 30s Playwright helper timeout),
Mocha kept running in the background, eventually entered paused state
forever (because cancelRun had reset abortRun=false), and every
subsequent run_test threw "Mocha instance is currently running tests".
The only recovery was killing the MCP process.
Three changes:
- lib/codecept.js: capture the Runner returned by mocha.run() as
mocha.runner, so callers have a clean handle to abort. Previously
the return value was discarded.
- cancelRun(): call mocha.runner.abort() to actually stop Mocha (sets
the runner's _abort flag, makes the run callback fire fast). Drop
the 5s race against pendingRunPromise — with runner.abort() the
promise settles quickly; relying on a short race meant a 30s
Playwright step would outlive the cancel and Mocha state stayed
RUNNING.
- abortRun lifecycle: stop resetting it inside cancelRun. Reset it at
the start of each new run_test / run_step_by_step instead. This way
if a late pause() fires after cancelRun returns (test reached pause
asynchronously after the timeout), setPauseHandler still rejects it
instead of trapping forever.
Repro fixed:
run_test({timeout: 50}) → Timeout after 50ms
run_test({timeout: 60000}) → completed, stats: {tests:1, passes:1}
(was: second call permanently failed with "Mocha is already running")
Refs: testomatio/e2e-tests#103
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fixed autoexit
---------
Co-authored-by: DavertMik <davert@testomat.io>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0c07a9c commit fb28db2
7 files changed
Lines changed: 39 additions & 39 deletions
File tree
- bin
- lib
- command
- plugin
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
404 | 408 | | |
405 | | - | |
| 409 | + | |
406 | 410 | | |
407 | 411 | | |
408 | 412 | | |
409 | 413 | | |
410 | 414 | | |
411 | | - | |
412 | 415 | | |
413 | 416 | | |
414 | 417 | | |
| |||
1032 | 1035 | | |
1033 | 1036 | | |
1034 | 1037 | | |
| 1038 | + | |
1035 | 1039 | | |
1036 | 1040 | | |
1037 | 1041 | | |
| |||
1126 | 1130 | | |
1127 | 1131 | | |
1128 | 1132 | | |
| 1133 | + | |
1129 | 1134 | | |
1130 | 1135 | | |
1131 | 1136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | | - | |
| 319 | + | |
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | 90 | | |
105 | 91 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 45 | + | |
60 | 46 | | |
61 | 47 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
110 | 124 | | |
111 | 125 | | |
112 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
147 | 150 | | |
148 | 151 | | |
149 | 152 | | |
150 | | - | |
151 | | - | |
152 | | - | |
| 153 | + | |
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
550 | | - | |
| 550 | + | |
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
| 554 | + | |
554 | 555 | | |
555 | 556 | | |
556 | 557 | | |
| |||
611 | 612 | | |
612 | 613 | | |
613 | 614 | | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
614 | 622 | | |
615 | 623 | | |
616 | 624 | | |
| |||
741 | 749 | | |
742 | 750 | | |
743 | 751 | | |
744 | | - | |
745 | | - | |
| 752 | + | |
| 753 | + | |
746 | 754 | | |
747 | 755 | | |
748 | 756 | | |
| |||
0 commit comments