@eggjs/mock 6.0.7 → 6.1.0-beta.10

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 (309) hide show
  1. package/README.md +35 -56
  2. package/README.zh_CN.md +30 -50
  3. package/dist/_virtual/rolldown_runtime.js +30 -0
  4. package/dist/app/extend/agent.d.ts +39 -0
  5. package/dist/app/extend/agent.js +48 -0
  6. package/dist/app/extend/application.d.ts +175 -0
  7. package/dist/app/extend/application.js +385 -0
  8. package/dist/app/middleware/cluster_app_mock.d.ts +6 -0
  9. package/dist/app/middleware/cluster_app_mock.js +97 -0
  10. package/dist/app.d.ts +10 -0
  11. package/dist/app.js +17 -0
  12. package/dist/bootstrap.d.ts +9 -0
  13. package/dist/bootstrap.js +14 -0
  14. package/dist/index.d.ts +81 -0
  15. package/dist/index.js +47 -0
  16. package/dist/inject_mocha.d.ts +1 -0
  17. package/dist/inject_mocha.js +35 -0
  18. package/dist/lib/agent_handler.d.ts +7 -0
  19. package/dist/lib/agent_handler.js +26 -0
  20. package/dist/lib/app.d.ts +7 -0
  21. package/dist/lib/app.js +251 -0
  22. package/dist/lib/app_handler.d.ts +9 -0
  23. package/dist/lib/app_handler.js +56 -0
  24. package/dist/lib/cluster.d.ts +126 -0
  25. package/dist/lib/cluster.js +283 -0
  26. package/dist/lib/context.d.ts +4 -0
  27. package/dist/lib/context.js +12 -0
  28. package/dist/lib/format_options.d.ts +10 -0
  29. package/dist/lib/format_options.js +65 -0
  30. package/dist/lib/inject_context.d.ts +9 -0
  31. package/dist/lib/inject_context.js +106 -0
  32. package/dist/lib/mock_agent.d.ts +9 -0
  33. package/dist/lib/mock_agent.js +45 -0
  34. package/dist/lib/mock_custom_loader.d.ts +4 -0
  35. package/dist/lib/mock_custom_loader.js +35 -0
  36. package/dist/lib/mock_http_server.d.ts +6 -0
  37. package/dist/lib/mock_http_server.js +17 -0
  38. package/dist/lib/mock_httpclient.d.ts +40 -0
  39. package/dist/lib/mock_httpclient.js +110 -0
  40. package/dist/lib/parallel/agent.d.ts +24 -0
  41. package/dist/lib/parallel/agent.js +111 -0
  42. package/dist/lib/parallel/app.d.ts +24 -0
  43. package/dist/lib/parallel/app.js +99 -0
  44. package/dist/lib/parallel/util.d.ts +6 -0
  45. package/dist/lib/parallel/util.js +59 -0
  46. package/dist/lib/prerequire.d.ts +1 -0
  47. package/dist/lib/prerequire.js +1 -0
  48. package/dist/lib/request_call_function.d.ts +1 -0
  49. package/dist/lib/request_call_function.js +37 -0
  50. package/dist/lib/restore.d.ts +4 -0
  51. package/dist/lib/restore.js +16 -0
  52. package/dist/lib/start-cluster.d.ts +1 -0
  53. package/dist/lib/start-cluster.js +19 -0
  54. package/dist/lib/supertest.d.ts +16 -0
  55. package/dist/lib/supertest.js +39 -0
  56. package/dist/lib/tmp/empty.d.ts +1 -0
  57. package/dist/lib/tmp/empty.js +1 -0
  58. package/{src/lib/types.ts → dist/lib/types.d.ts} +12 -29
  59. package/dist/lib/types.js +1 -0
  60. package/dist/lib/utils.d.ts +12 -0
  61. package/dist/lib/utils.js +40 -0
  62. package/dist/node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js +142 -0
  63. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js +157 -0
  64. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js +97 -0
  65. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js +40 -0
  66. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js +814 -0
  67. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js +50 -0
  68. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js +68 -0
  69. package/dist/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js +752 -0
  70. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js +203 -0
  71. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js +209 -0
  72. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js +18 -0
  73. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js +215 -0
  74. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/dmp.js +24 -0
  75. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/xml.js +33 -0
  76. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/array.js +29 -0
  77. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/base.js +185 -0
  78. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/character.js +23 -0
  79. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/css.js +26 -0
  80. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/json.js +83 -0
  81. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/line.js +51 -0
  82. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/sentence.js +26 -0
  83. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/word.js +151 -0
  84. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.js +178 -0
  85. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/apply.js +168 -0
  86. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/create.js +301 -0
  87. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/line-endings.js +137 -0
  88. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/merge.js +367 -0
  89. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/parse.js +91 -0
  90. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/reverse.js +99 -0
  91. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/array.js +23 -0
  92. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/distance-iterator.js +30 -0
  93. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/params.js +22 -0
  94. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/string.js +97 -0
  95. package/dist/node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js +14 -0
  96. package/dist/node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js +16 -0
  97. package/dist/node_modules/.pnpm/he@1.2.0/node_modules/he/he.js +4093 -0
  98. package/dist/node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js +14 -0
  99. package/dist/node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js +27 -0
  100. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/index.js +12 -0
  101. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/context.js +83 -0
  102. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/error-constants.js +35 -0
  103. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/errors.js +392 -0
  104. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/hook.js +86 -0
  105. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/bdd.js +104 -0
  106. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/common.js +99 -0
  107. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/exports.js +65 -0
  108. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/index.js +18 -0
  109. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/qunit.js +95 -0
  110. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/tdd.js +105 -0
  111. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocha.js +1037 -0
  112. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocharc.js +24 -0
  113. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js +152 -0
  114. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/esm-utils.js +74 -0
  115. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/file-unloader.js +22 -0
  116. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js +329 -0
  117. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/serializer.js +314 -0
  118. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/pending.js +22 -0
  119. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/base.js +417 -0
  120. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/doc.js +79 -0
  121. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/dot.js +75 -0
  122. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/html.js +283 -0
  123. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/index.js +40 -0
  124. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json-stream.js +90 -0
  125. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json.js +145 -0
  126. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/landing.js +107 -0
  127. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/list.js +77 -0
  128. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/markdown.js +106 -0
  129. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/min.js +57 -0
  130. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/nyan.js +233 -0
  131. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/progress.js +92 -0
  132. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/spec.js +91 -0
  133. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/tap.js +261 -0
  134. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/xunit.js +166 -0
  135. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js +346 -0
  136. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runner.js +922 -0
  137. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js +72 -0
  138. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js +517 -0
  139. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js +105 -0
  140. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/utils.js +505 -0
  141. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/package.js +225 -0
  142. package/dist/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +124 -0
  143. package/dist/node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js +11 -0
  144. package/dist/node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js +114 -0
  145. package/dist/node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js +76 -0
  146. package/dist/node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js +89 -0
  147. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Pool.js +366 -0
  148. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Promise.js +248 -0
  149. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/WorkerHandler.js +419 -0
  150. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/debug-port-allocator.js +27 -0
  151. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/environment.js +18 -0
  152. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/generated/embeddedWorker.js +16 -0
  153. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/index.js +63 -0
  154. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/transfer.js +21 -0
  155. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/validateOptions.js +9 -0
  156. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js +277 -0
  157. package/dist/register.d.ts +10 -0
  158. package/dist/register.js +40 -0
  159. package/dist/typings/index.d.ts +1 -0
  160. package/package.json +71 -98
  161. package/dist/commonjs/app/extend/agent.d.ts +0 -34
  162. package/dist/commonjs/app/extend/agent.js +0 -49
  163. package/dist/commonjs/app/extend/application.d.ts +0 -172
  164. package/dist/commonjs/app/extend/application.js +0 -450
  165. package/dist/commonjs/app/middleware/cluster_app_mock.d.ts +0 -3
  166. package/dist/commonjs/app/middleware/cluster_app_mock.js +0 -101
  167. package/dist/commonjs/app.d.ts +0 -6
  168. package/dist/commonjs/app.js +0 -20
  169. package/dist/commonjs/bootstrap.d.ts +0 -5
  170. package/dist/commonjs/bootstrap.js +0 -59
  171. package/dist/commonjs/index.d.ts +0 -77
  172. package/dist/commonjs/index.js +0 -114
  173. package/dist/commonjs/lib/agent_handler.d.ts +0 -3
  174. package/dist/commonjs/lib/agent_handler.js +0 -28
  175. package/dist/commonjs/lib/app.d.ts +0 -3
  176. package/dist/commonjs/lib/app.js +0 -301
  177. package/dist/commonjs/lib/app_handler.d.ts +0 -5
  178. package/dist/commonjs/lib/app_handler.js +0 -71
  179. package/dist/commonjs/lib/cluster.d.ts +0 -114
  180. package/dist/commonjs/lib/cluster.js +0 -337
  181. package/dist/commonjs/lib/context.d.ts +0 -1
  182. package/dist/commonjs/lib/context.js +0 -16
  183. package/dist/commonjs/lib/format_options.d.ts +0 -5
  184. package/dist/commonjs/lib/format_options.js +0 -100
  185. package/dist/commonjs/lib/inject_context.d.ts +0 -6
  186. package/dist/commonjs/lib/inject_context.js +0 -132
  187. package/dist/commonjs/lib/mock_agent.d.ts +0 -5
  188. package/dist/commonjs/lib/mock_agent.js +0 -49
  189. package/dist/commonjs/lib/mock_custom_loader.d.ts +0 -1
  190. package/dist/commonjs/lib/mock_custom_loader.js +0 -37
  191. package/dist/commonjs/lib/mock_http_server.d.ts +0 -2
  192. package/dist/commonjs/lib/mock_http_server.js +0 -24
  193. package/dist/commonjs/lib/mock_httpclient.d.ts +0 -36
  194. package/dist/commonjs/lib/mock_httpclient.js +0 -147
  195. package/dist/commonjs/lib/parallel/agent.d.ts +0 -20
  196. package/dist/commonjs/lib/parallel/agent.js +0 -125
  197. package/dist/commonjs/lib/parallel/app.d.ts +0 -20
  198. package/dist/commonjs/lib/parallel/app.js +0 -115
  199. package/dist/commonjs/lib/parallel/util.d.ts +0 -3
  200. package/dist/commonjs/lib/parallel/util.js +0 -77
  201. package/dist/commonjs/lib/prerequire.d.ts +0 -1
  202. package/dist/commonjs/lib/prerequire.js +0 -26
  203. package/dist/commonjs/lib/request_call_function.d.ts +0 -1
  204. package/dist/commonjs/lib/request_call_function.js +0 -52
  205. package/dist/commonjs/lib/restore.d.ts +0 -1
  206. package/dist/commonjs/lib/restore.js +0 -16
  207. package/dist/commonjs/lib/start-cluster.d.ts +0 -2
  208. package/dist/commonjs/lib/start-cluster.js +0 -23
  209. package/dist/commonjs/lib/supertest.d.ts +0 -11
  210. package/dist/commonjs/lib/supertest.js +0 -48
  211. package/dist/commonjs/lib/tmp/empty.d.ts +0 -1
  212. package/dist/commonjs/lib/tmp/empty.js +0 -3
  213. package/dist/commonjs/lib/types.d.ts +0 -68
  214. package/dist/commonjs/lib/types.js +0 -3
  215. package/dist/commonjs/lib/utils.d.ts +0 -9
  216. package/dist/commonjs/lib/utils.js +0 -80
  217. package/dist/commonjs/package.json +0 -3
  218. package/dist/commonjs/register.d.ts +0 -8
  219. package/dist/commonjs/register.js +0 -80
  220. package/dist/esm/app/extend/agent.d.ts +0 -34
  221. package/dist/esm/app/extend/agent.js +0 -46
  222. package/dist/esm/app/extend/application.d.ts +0 -172
  223. package/dist/esm/app/extend/application.js +0 -444
  224. package/dist/esm/app/middleware/cluster_app_mock.d.ts +0 -3
  225. package/dist/esm/app/middleware/cluster_app_mock.js +0 -99
  226. package/dist/esm/app.d.ts +0 -6
  227. package/dist/esm/app.js +0 -17
  228. package/dist/esm/bootstrap.d.ts +0 -5
  229. package/dist/esm/bootstrap.js +0 -15
  230. package/dist/esm/index.d.ts +0 -77
  231. package/dist/esm/index.js +0 -91
  232. package/dist/esm/lib/agent_handler.d.ts +0 -3
  233. package/dist/esm/lib/agent_handler.js +0 -24
  234. package/dist/esm/lib/app.d.ts +0 -3
  235. package/dist/esm/lib/app.js +0 -295
  236. package/dist/esm/lib/app_handler.d.ts +0 -5
  237. package/dist/esm/lib/app_handler.js +0 -65
  238. package/dist/esm/lib/cluster.d.ts +0 -114
  239. package/dist/esm/lib/cluster.js +0 -328
  240. package/dist/esm/lib/context.d.ts +0 -1
  241. package/dist/esm/lib/context.js +0 -13
  242. package/dist/esm/lib/format_options.d.ts +0 -5
  243. package/dist/esm/lib/format_options.js +0 -94
  244. package/dist/esm/lib/inject_context.d.ts +0 -6
  245. package/dist/esm/lib/inject_context.js +0 -126
  246. package/dist/esm/lib/mock_agent.d.ts +0 -5
  247. package/dist/esm/lib/mock_agent.js +0 -45
  248. package/dist/esm/lib/mock_custom_loader.d.ts +0 -1
  249. package/dist/esm/lib/mock_custom_loader.js +0 -34
  250. package/dist/esm/lib/mock_http_server.d.ts +0 -2
  251. package/dist/esm/lib/mock_http_server.js +0 -18
  252. package/dist/esm/lib/mock_httpclient.d.ts +0 -36
  253. package/dist/esm/lib/mock_httpclient.js +0 -144
  254. package/dist/esm/lib/parallel/agent.d.ts +0 -20
  255. package/dist/esm/lib/parallel/agent.js +0 -117
  256. package/dist/esm/lib/parallel/app.d.ts +0 -20
  257. package/dist/esm/lib/parallel/app.js +0 -110
  258. package/dist/esm/lib/parallel/util.d.ts +0 -3
  259. package/dist/esm/lib/parallel/util.js +0 -73
  260. package/dist/esm/lib/prerequire.d.ts +0 -1
  261. package/dist/esm/lib/prerequire.js +0 -25
  262. package/dist/esm/lib/request_call_function.d.ts +0 -1
  263. package/dist/esm/lib/request_call_function.js +0 -47
  264. package/dist/esm/lib/restore.d.ts +0 -1
  265. package/dist/esm/lib/restore.js +0 -13
  266. package/dist/esm/lib/start-cluster.d.ts +0 -2
  267. package/dist/esm/lib/start-cluster.js +0 -18
  268. package/dist/esm/lib/supertest.d.ts +0 -11
  269. package/dist/esm/lib/supertest.js +0 -40
  270. package/dist/esm/lib/tmp/empty.d.ts +0 -1
  271. package/dist/esm/lib/tmp/empty.js +0 -2
  272. package/dist/esm/lib/types.d.ts +0 -68
  273. package/dist/esm/lib/types.js +0 -2
  274. package/dist/esm/lib/utils.d.ts +0 -9
  275. package/dist/esm/lib/utils.js +0 -69
  276. package/dist/esm/package.json +0 -3
  277. package/dist/esm/register.d.ts +0 -8
  278. package/dist/esm/register.js +0 -75
  279. package/dist/package.json +0 -4
  280. package/src/app/extend/agent.ts +0 -57
  281. package/src/app/extend/application.ts +0 -512
  282. package/src/app/middleware/cluster_app_mock.ts +0 -102
  283. package/src/app.ts +0 -18
  284. package/src/bootstrap.ts +0 -25
  285. package/src/index.ts +0 -112
  286. package/src/lib/agent_handler.ts +0 -28
  287. package/src/lib/app.ts +0 -314
  288. package/src/lib/app_handler.ts +0 -77
  289. package/src/lib/cluster.ts +0 -363
  290. package/src/lib/context.ts +0 -14
  291. package/src/lib/format_options.ts +0 -103
  292. package/src/lib/inject_context.ts +0 -134
  293. package/src/lib/mock_agent.ts +0 -57
  294. package/src/lib/mock_custom_loader.ts +0 -36
  295. package/src/lib/mock_http_server.ts +0 -19
  296. package/src/lib/mock_httpclient.ts +0 -183
  297. package/src/lib/parallel/agent.ts +0 -128
  298. package/src/lib/parallel/app.ts +0 -123
  299. package/src/lib/parallel/util.ts +0 -66
  300. package/src/lib/prerequire.ts +0 -25
  301. package/src/lib/request_call_function.ts +0 -49
  302. package/src/lib/restore.ts +0 -14
  303. package/src/lib/start-cluster.ts +0 -23
  304. package/src/lib/supertest.ts +0 -45
  305. package/src/lib/tmp/.gitkeep +0 -0
  306. package/src/lib/tmp/empty.ts +0 -0
  307. package/src/lib/utils.ts +0 -82
  308. package/src/register.ts +0 -80
  309. package/src/typings/index.d.ts +0 -4
@@ -0,0 +1,1037 @@
1
+ import { __commonJS, __require } from "../../../../../../_virtual/rolldown_runtime.js";
2
+ import { require_escape_string_regexp } from "../../../../escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js";
3
+ import { require_utils } from "./utils.js";
4
+ import { require_src } from "../../../../debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js";
5
+ import { require_errors } from "./errors.js";
6
+ import { require_runnable } from "./runnable.js";
7
+ import { require_hook } from "./hook.js";
8
+ import { require_suite } from "./suite.js";
9
+ import { require_runner } from "./runner.js";
10
+ import { require_reporters } from "./reporters/index.js";
11
+ import { require_mocharc } from "./mocharc.js";
12
+ import { require_esm_utils } from "./nodejs/esm-utils.js";
13
+ import { require_stats_collector } from "./stats-collector.js";
14
+ import { require_test } from "./test.js";
15
+ import { require_interfaces } from "./interfaces/index.js";
16
+ import { require_context } from "./context.js";
17
+ import { require_file_unloader } from "./nodejs/file-unloader.js";
18
+ import { require_package } from "../package.js";
19
+ import { require_parallel_buffered_runner } from "./nodejs/parallel-buffered-runner.js";
20
+
21
+ //#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocha.js
22
+ var require_mocha = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocha.js": ((exports, module) => {
23
+ /*!
24
+ * mocha
25
+ * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
26
+ * MIT Licensed
27
+ */
28
+ var escapeRe = require_escape_string_regexp();
29
+ var path = __require("node:path");
30
+ var builtinReporters = require_reporters();
31
+ var utils = require_utils();
32
+ var mocharc = require_mocharc();
33
+ var Suite = require_suite();
34
+ var esmUtils = require_esm_utils();
35
+ var createStatsCollector = require_stats_collector();
36
+ const { createInvalidReporterError, createInvalidInterfaceError, createMochaInstanceAlreadyDisposedError, createMochaInstanceAlreadyRunningError, createUnsupportedError } = require_errors();
37
+ const { EVENT_FILE_PRE_REQUIRE, EVENT_FILE_POST_REQUIRE, EVENT_FILE_REQUIRE } = Suite.constants;
38
+ var debug = require_src()("mocha:mocha");
39
+ /**
40
+ * @typedef {import('./types.d.ts').DoneCB} DoneCB
41
+ * @typedef {import('./types.d.ts').MochaGlobalFixture} MochaGlobalFixture
42
+ * @typedef {import('./types.d.ts').MochaOptions} MochaOptions
43
+ * @typedef {import('./types.d.ts').MochaRootHookObject} MochaRootHookObject
44
+ * @typedef {import('./types.d.ts').Reporter} Reporter
45
+ */
46
+ exports = module.exports = Mocha;
47
+ /**
48
+ * A Mocha instance is a finite state machine.
49
+ * These are the states it can be in.
50
+ * @private
51
+ */
52
+ var mochaStates = utils.defineConstants({
53
+ INIT: "init",
54
+ RUNNING: "running",
55
+ REFERENCES_CLEANED: "referencesCleaned",
56
+ DISPOSED: "disposed"
57
+ });
58
+ /**
59
+ * To require local UIs and reporters when running in node.
60
+ */
61
+ if (!utils.isBrowser() && typeof module.paths !== "undefined") {
62
+ var cwd = utils.cwd();
63
+ module.paths.push(cwd, path.join(cwd, "node_modules"));
64
+ }
65
+ /**
66
+ * Expose internals.
67
+ * @private
68
+ */
69
+ exports.utils = utils;
70
+ exports.interfaces = require_interfaces();
71
+ /**
72
+ * @public
73
+ * @memberof Mocha
74
+ */
75
+ exports.reporters = builtinReporters;
76
+ exports.Runnable = require_runnable();
77
+ exports.Context = require_context();
78
+ /**
79
+ *
80
+ * @memberof Mocha
81
+ */
82
+ exports.Runner = require_runner();
83
+ exports.Suite = Suite;
84
+ exports.Hook = require_hook();
85
+ exports.Test = require_test();
86
+ let currentContext;
87
+ exports.afterEach = function(...args) {
88
+ return (currentContext.afterEach || currentContext.teardown).apply(this, args);
89
+ };
90
+ exports.after = function(...args) {
91
+ return (currentContext.after || currentContext.suiteTeardown).apply(this, args);
92
+ };
93
+ exports.beforeEach = function(...args) {
94
+ return (currentContext.beforeEach || currentContext.setup).apply(this, args);
95
+ };
96
+ exports.before = function(...args) {
97
+ return (currentContext.before || currentContext.suiteSetup).apply(this, args);
98
+ };
99
+ exports.describe = function(...args) {
100
+ return (currentContext.describe || currentContext.suite).apply(this, args);
101
+ };
102
+ exports.describe.only = function(...args) {
103
+ return (currentContext.describe || currentContext.suite).only.apply(this, args);
104
+ };
105
+ exports.describe.skip = function(...args) {
106
+ return (currentContext.describe || currentContext.suite).skip.apply(this, args);
107
+ };
108
+ exports.it = function(...args) {
109
+ return (currentContext.it || currentContext.test).apply(this, args);
110
+ };
111
+ exports.it.only = function(...args) {
112
+ return (currentContext.it || currentContext.test).only.apply(this, args);
113
+ };
114
+ exports.it.skip = function(...args) {
115
+ return (currentContext.it || currentContext.test).skip.apply(this, args);
116
+ };
117
+ exports.xdescribe = exports.describe.skip;
118
+ exports.xit = exports.it.skip;
119
+ exports.setup = exports.beforeEach;
120
+ exports.suiteSetup = exports.before;
121
+ exports.suiteTeardown = exports.after;
122
+ exports.suite = exports.describe;
123
+ exports.teardown = exports.afterEach;
124
+ exports.test = exports.it;
125
+ exports.run = function(...args) {
126
+ return currentContext.run.apply(this, args);
127
+ };
128
+ /**
129
+ * Constructs a new Mocha instance with `options`.
130
+ *
131
+ * @public
132
+ * @class Mocha
133
+ * @param {MochaOptions} [options] - Settings object.
134
+ */
135
+ function Mocha(options = {}) {
136
+ options = {
137
+ ...mocharc,
138
+ ...options
139
+ };
140
+ this.files = [];
141
+ this.options = options;
142
+ this.suite = new exports.Suite("", new exports.Context(), true);
143
+ this._cleanReferencesAfterRun = true;
144
+ this._state = mochaStates.INIT;
145
+ this.grep(options.grep).fgrep(options.fgrep).ui(options.ui).reporter(options.reporter, options["reporter-option"] || options.reporterOption || options.reporterOptions).slow(options.slow).global(options.global);
146
+ if (typeof options.timeout !== "undefined") this.timeout(options.timeout === false ? 0 : options.timeout);
147
+ if ("retries" in options) this.retries(options.retries);
148
+ [
149
+ "allowUncaught",
150
+ "asyncOnly",
151
+ "bail",
152
+ "checkLeaks",
153
+ "color",
154
+ "delay",
155
+ "diff",
156
+ "dryRun",
157
+ "passOnFailingTestSuite",
158
+ "failZero",
159
+ "forbidOnly",
160
+ "forbidPending",
161
+ "fullTrace",
162
+ "inlineDiffs",
163
+ "invert"
164
+ ].forEach(function(opt) {
165
+ if (options[opt]) this[opt]();
166
+ }, this);
167
+ if (options.rootHooks) this.rootHooks(options.rootHooks);
168
+ /**
169
+ * The class which we'll instantiate in {@link Mocha#run}. Defaults to
170
+ * {@link Runner} in serial mode; changes in parallel mode.
171
+ * @memberof Mocha
172
+ * @private
173
+ */
174
+ this._runnerClass = exports.Runner;
175
+ /**
176
+ * Whether or not to call {@link Mocha#loadFiles} implicitly when calling
177
+ * {@link Mocha#run}. If this is `true`, then it's up to the consumer to call
178
+ * {@link Mocha#loadFiles} _or_ {@link Mocha#loadFilesAsync}.
179
+ * @private
180
+ * @memberof Mocha
181
+ */
182
+ this._lazyLoadFiles = false;
183
+ /**
184
+ * It's useful for a Mocha instance to know if it's running in a worker process.
185
+ * We could derive this via other means, but it's helpful to have a flag to refer to.
186
+ * @memberof Mocha
187
+ * @private
188
+ */
189
+ this.isWorker = Boolean(options.isWorker);
190
+ this.globalSetup(options.globalSetup).globalTeardown(options.globalTeardown).enableGlobalSetup(options.enableGlobalSetup).enableGlobalTeardown(options.enableGlobalTeardown);
191
+ if (options.parallel && (typeof options.jobs === "undefined" || options.jobs > 1)) {
192
+ debug("attempting to enable parallel mode");
193
+ this.parallelMode(true);
194
+ }
195
+ }
196
+ /**
197
+ * Enables or disables bailing on the first failure.
198
+ *
199
+ * @public
200
+ * @see [CLI option](../#-bail-b)
201
+ * @param {boolean} [bail=true] - Whether to bail on first error.
202
+ * @returns {Mocha} this
203
+ * @chainable
204
+ */
205
+ Mocha.prototype.bail = function(bail) {
206
+ this.suite.bail(bail !== false);
207
+ return this;
208
+ };
209
+ /**
210
+ * @summary
211
+ * Adds `file` to be loaded for execution.
212
+ *
213
+ * @description
214
+ * Useful for generic setup code that must be included within test suite.
215
+ *
216
+ * @public
217
+ * @see [CLI option](../#-file-filedirectoryglob)
218
+ * @param {string} file - Pathname of file to be loaded.
219
+ * @returns {Mocha} this
220
+ * @chainable
221
+ */
222
+ Mocha.prototype.addFile = function(file) {
223
+ this.files.push(file);
224
+ return this;
225
+ };
226
+ /**
227
+ * Sets reporter to `reporter`, defaults to "spec".
228
+ *
229
+ * @public
230
+ * @see [CLI option](../#-reporter-name-r-name)
231
+ * @see [Reporters](../#reporters)
232
+ * @param {String|Reporter} reporterName - Reporter name or constructor.
233
+ * @param {Object} [reporterOptions] - Options used to configure the reporter.
234
+ * @returns {Mocha} this
235
+ * @chainable
236
+ * @throws {Error} if requested reporter cannot be loaded
237
+ * @example
238
+ *
239
+ * // Use XUnit reporter and direct its output to file
240
+ * mocha.reporter('xunit', { output: '/path/to/testspec.xunit.xml' });
241
+ */
242
+ Mocha.prototype.reporter = function(reporterName, reporterOptions) {
243
+ if (typeof reporterName === "function") this._reporter = reporterName;
244
+ else {
245
+ reporterName = reporterName || "spec";
246
+ var reporter;
247
+ if (builtinReporters[reporterName]) reporter = builtinReporters[reporterName];
248
+ if (!reporter) {
249
+ let foundReporter;
250
+ try {
251
+ foundReporter = __require.resolve(reporterName);
252
+ reporter = __require(foundReporter);
253
+ } catch (err) {
254
+ if (foundReporter) throw createInvalidReporterError(err.message, foundReporter);
255
+ try {
256
+ reporter = __require(path.resolve(reporterName));
257
+ } catch (err$1) {
258
+ throw createInvalidReporterError(err$1.message, reporterName);
259
+ }
260
+ }
261
+ }
262
+ this._reporter = reporter;
263
+ }
264
+ this.options.reporterOption = reporterOptions;
265
+ this.options.reporterOptions = reporterOptions;
266
+ return this;
267
+ };
268
+ /**
269
+ * Sets test UI `name`, defaults to "bdd".
270
+ *
271
+ * @public
272
+ * @see [CLI option](../#-ui-name-u-name)
273
+ * @see [Interface DSLs](../#interfaces)
274
+ * @param {string|Function} [ui=bdd] - Interface name or class.
275
+ * @returns {Mocha} this
276
+ * @chainable
277
+ * @throws {Error} if requested interface cannot be loaded
278
+ */
279
+ Mocha.prototype.ui = function(ui) {
280
+ var bindInterface;
281
+ if (typeof ui === "function") bindInterface = ui;
282
+ else {
283
+ ui = ui || "bdd";
284
+ bindInterface = exports.interfaces[ui];
285
+ if (!bindInterface) try {
286
+ bindInterface = __require(ui);
287
+ } catch (err) {
288
+ throw createInvalidInterfaceError(`invalid interface '${ui}'`, ui);
289
+ }
290
+ }
291
+ bindInterface(this.suite);
292
+ this.suite.on(EVENT_FILE_PRE_REQUIRE, function(context) {
293
+ currentContext = context;
294
+ });
295
+ return this;
296
+ };
297
+ /**
298
+ * Loads `files` prior to execution. Does not support ES Modules.
299
+ *
300
+ * @description
301
+ * The implementation relies on Node's `require` to execute
302
+ * the test interface functions and will be subject to its cache.
303
+ * Supports only CommonJS modules. To load ES modules, use Mocha#loadFilesAsync.
304
+ *
305
+ * @private
306
+ * @see {@link Mocha#addFile}
307
+ * @see {@link Mocha#run}
308
+ * @see {@link Mocha#unloadFiles}
309
+ * @see {@link Mocha#loadFilesAsync}
310
+ * @param {Function} [fn] - Callback invoked upon completion.
311
+ */
312
+ Mocha.prototype.loadFiles = function(fn) {
313
+ var self = this;
314
+ var suite = this.suite;
315
+ this.files.forEach(function(file) {
316
+ file = path.resolve(file);
317
+ suite.emit(EVENT_FILE_PRE_REQUIRE, global, file, self);
318
+ suite.emit(EVENT_FILE_REQUIRE, __require(file), file, self);
319
+ suite.emit(EVENT_FILE_POST_REQUIRE, global, file, self);
320
+ });
321
+ fn && fn();
322
+ };
323
+ /**
324
+ * Loads `files` prior to execution. Supports Node ES Modules.
325
+ *
326
+ * @description
327
+ * The implementation relies on Node's `require` and `import` to execute
328
+ * the test interface functions and will be subject to its cache.
329
+ * Supports both CJS and ESM modules.
330
+ *
331
+ * @public
332
+ * @see {@link Mocha#addFile}
333
+ * @see {@link Mocha#run}
334
+ * @see {@link Mocha#unloadFiles}
335
+ * @param {Object} [options] - Settings object.
336
+ * @param {Function} [options.esmDecorator] - Function invoked on esm module name right before importing it. By default will passthrough as is.
337
+ * @returns {Promise}
338
+ * @example
339
+ *
340
+ * // loads ESM (and CJS) test files asynchronously, then runs root suite
341
+ * mocha.loadFilesAsync()
342
+ * .then(() => mocha.run(failures => process.exitCode = failures ? 1 : 0))
343
+ * .catch(() => process.exitCode = 1);
344
+ */
345
+ Mocha.prototype.loadFilesAsync = function({ esmDecorator } = {}) {
346
+ var self = this;
347
+ var suite = this.suite;
348
+ this.lazyLoadFiles(true);
349
+ return esmUtils.loadFilesAsync(this.files, function(file) {
350
+ suite.emit(EVENT_FILE_PRE_REQUIRE, global, file, self);
351
+ }, function(file, resultModule) {
352
+ suite.emit(EVENT_FILE_REQUIRE, resultModule, file, self);
353
+ suite.emit(EVENT_FILE_POST_REQUIRE, global, file, self);
354
+ }, esmDecorator);
355
+ };
356
+ /**
357
+ * Removes a previously loaded file from Node's `require` cache.
358
+ *
359
+ * @private
360
+ * @static
361
+ * @see {@link Mocha#unloadFiles}
362
+ * @param {string} file - Pathname of file to be unloaded.
363
+ */
364
+ Mocha.unloadFile = function(file) {
365
+ if (utils.isBrowser()) throw createUnsupportedError("unloadFile() is only supported in a Node.js environment");
366
+ return require_file_unloader().unloadFile(file);
367
+ };
368
+ /**
369
+ * Unloads `files` from Node's `require` cache.
370
+ *
371
+ * @description
372
+ * This allows required files to be "freshly" reloaded, providing the ability
373
+ * to reuse a Mocha instance programmatically.
374
+ * Note: does not clear ESM module files from the cache
375
+ *
376
+ * <strong>Intended for consumers &mdash; not used internally</strong>
377
+ *
378
+ * @public
379
+ * @see {@link Mocha#run}
380
+ * @returns {Mocha} this
381
+ * @chainable
382
+ */
383
+ Mocha.prototype.unloadFiles = function() {
384
+ if (this._state === mochaStates.DISPOSED) throw createMochaInstanceAlreadyDisposedError("Mocha instance is already disposed, it cannot be used again.", this._cleanReferencesAfterRun, this);
385
+ this.files.forEach(function(file) {
386
+ Mocha.unloadFile(file);
387
+ });
388
+ this._state = mochaStates.INIT;
389
+ return this;
390
+ };
391
+ /**
392
+ * Sets `grep` filter after escaping RegExp special characters.
393
+ *
394
+ * @public
395
+ * @see {@link Mocha#grep}
396
+ * @param {string} str - Value to be converted to a regexp.
397
+ * @returns {Mocha} this
398
+ * @chainable
399
+ * @example
400
+ *
401
+ * // Select tests whose full title begins with `"foo"` followed by a period
402
+ * mocha.fgrep('foo.');
403
+ */
404
+ Mocha.prototype.fgrep = function(str) {
405
+ if (!str) return this;
406
+ return this.grep(new RegExp(escapeRe(str)));
407
+ };
408
+ /**
409
+ * @summary
410
+ * Sets `grep` filter used to select specific tests for execution.
411
+ *
412
+ * @description
413
+ * If `re` is a regexp-like string, it will be converted to regexp.
414
+ * The regexp is tested against the full title of each test (i.e., the
415
+ * name of the test preceded by titles of each its ancestral suites).
416
+ * As such, using an <em>exact-match</em> fixed pattern against the
417
+ * test name itself will not yield any matches.
418
+ * <br>
419
+ * <strong>Previous filter value will be overwritten on each call!</strong>
420
+ *
421
+ * @public
422
+ * @see [CLI option](../#-grep-regexp-g-regexp)
423
+ * @see {@link Mocha#fgrep}
424
+ * @see {@link Mocha#invert}
425
+ * @param {RegExp|String} re - Regular expression used to select tests.
426
+ * @return {Mocha} this
427
+ * @chainable
428
+ * @example
429
+ *
430
+ * // Select tests whose full title contains `"match"`, ignoring case
431
+ * mocha.grep(/match/i);
432
+ * @example
433
+ *
434
+ * // Same as above but with regexp-like string argument
435
+ * mocha.grep('/match/i');
436
+ * @example
437
+ *
438
+ * // ## Anti-example
439
+ * // Given embedded test `it('only-this-test')`...
440
+ * mocha.grep('/^only-this-test$/'); // NO! Use `.only()` to do this!
441
+ */
442
+ Mocha.prototype.grep = function(re) {
443
+ if (utils.isString(re)) {
444
+ var arg = re.match(/^\/(.*)\/([gimy]{0,4})$|.*/);
445
+ this.options.grep = new RegExp(arg[1] || arg[0], arg[2]);
446
+ } else this.options.grep = re;
447
+ return this;
448
+ };
449
+ /**
450
+ * Inverts `grep` matches.
451
+ *
452
+ * @public
453
+ * @see {@link Mocha#grep}
454
+ * @return {Mocha} this
455
+ * @chainable
456
+ * @example
457
+ *
458
+ * // Select tests whose full title does *not* contain `"match"`, ignoring case
459
+ * mocha.grep(/match/i).invert();
460
+ */
461
+ Mocha.prototype.invert = function() {
462
+ this.options.invert = true;
463
+ return this;
464
+ };
465
+ /**
466
+ * Enables or disables checking for global variables leaked while running tests.
467
+ *
468
+ * @public
469
+ * @see [CLI option](../#-check-leaks)
470
+ * @param {boolean} [checkLeaks=true] - Whether to check for global variable leaks.
471
+ * @return {Mocha} this
472
+ * @chainable
473
+ */
474
+ Mocha.prototype.checkLeaks = function(checkLeaks) {
475
+ this.options.checkLeaks = checkLeaks !== false;
476
+ return this;
477
+ };
478
+ /**
479
+ * Enables or disables whether or not to dispose after each test run.
480
+ * Disable this to ensure you can run the test suite multiple times.
481
+ * If disabled, be sure to dispose mocha when you're done to prevent memory leaks.
482
+ * @public
483
+ * @see {@link Mocha#dispose}
484
+ * @param {boolean} cleanReferencesAfterRun
485
+ * @return {Mocha} this
486
+ * @chainable
487
+ */
488
+ Mocha.prototype.cleanReferencesAfterRun = function(cleanReferencesAfterRun) {
489
+ this._cleanReferencesAfterRun = cleanReferencesAfterRun !== false;
490
+ return this;
491
+ };
492
+ /**
493
+ * Manually dispose this mocha instance. Mark this instance as `disposed` and unable to run more tests.
494
+ * It also removes function references to tests functions and hooks, so variables trapped in closures can be cleaned by the garbage collector.
495
+ * @public
496
+ */
497
+ Mocha.prototype.dispose = function() {
498
+ if (this._state === mochaStates.RUNNING) throw createMochaInstanceAlreadyRunningError("Cannot dispose while the mocha instance is still running tests.");
499
+ this.unloadFiles();
500
+ this._previousRunner && this._previousRunner.dispose();
501
+ this.suite.dispose();
502
+ this._state = mochaStates.DISPOSED;
503
+ };
504
+ /**
505
+ * Displays full stack trace upon test failure.
506
+ *
507
+ * @public
508
+ * @see [CLI option](../#-full-trace)
509
+ * @param {boolean} [fullTrace=true] - Whether to print full stacktrace upon failure.
510
+ * @return {Mocha} this
511
+ * @chainable
512
+ */
513
+ Mocha.prototype.fullTrace = function(fullTrace) {
514
+ this.options.fullTrace = fullTrace !== false;
515
+ return this;
516
+ };
517
+ /**
518
+ * Specifies whitelist of variable names to be expected in global scope.
519
+ *
520
+ * @public
521
+ * @see [CLI option](../#-global-variable-name)
522
+ * @see {@link Mocha#checkLeaks}
523
+ * @param {String[]|String} global - Accepted global variable name(s).
524
+ * @return {Mocha} this
525
+ * @chainable
526
+ * @example
527
+ *
528
+ * // Specify variables to be expected in global scope
529
+ * mocha.global(['jQuery', 'MyLib']);
530
+ */
531
+ Mocha.prototype.global = function(global$1) {
532
+ this.options.global = (this.options.global || []).concat(global$1).filter(Boolean).filter(function(elt, idx, arr) {
533
+ return arr.indexOf(elt) === idx;
534
+ });
535
+ return this;
536
+ };
537
+ Mocha.prototype.globals = Mocha.prototype.global;
538
+ /**
539
+ * Enables or disables TTY color output by screen-oriented reporters.
540
+ *
541
+ * @public
542
+ * @see [CLI option](../#-color-c-colors)
543
+ * @param {boolean} [color=true] - Whether to enable color output.
544
+ * @return {Mocha} this
545
+ * @chainable
546
+ */
547
+ Mocha.prototype.color = function(color) {
548
+ this.options.color = color !== false;
549
+ return this;
550
+ };
551
+ /**
552
+ * Enables or disables reporter to use inline diffs (rather than +/-)
553
+ * in test failure output.
554
+ *
555
+ * @public
556
+ * @see [CLI option](../#-inline-diffs)
557
+ * @param {boolean} [inlineDiffs=true] - Whether to use inline diffs.
558
+ * @return {Mocha} this
559
+ * @chainable
560
+ */
561
+ Mocha.prototype.inlineDiffs = function(inlineDiffs) {
562
+ this.options.inlineDiffs = inlineDiffs !== false;
563
+ return this;
564
+ };
565
+ /**
566
+ * Enables or disables reporter to include diff in test failure output.
567
+ *
568
+ * @public
569
+ * @see [CLI option](../#-diff)
570
+ * @param {boolean} [diff=true] - Whether to show diff on failure.
571
+ * @return {Mocha} this
572
+ * @chainable
573
+ */
574
+ Mocha.prototype.diff = function(diff) {
575
+ this.options.diff = diff !== false;
576
+ return this;
577
+ };
578
+ /**
579
+ * @summary
580
+ * Sets timeout threshold value.
581
+ *
582
+ * @description
583
+ * A string argument can use shorthand (such as "2s") and will be converted.
584
+ * If the value is `0`, timeouts will be disabled.
585
+ *
586
+ * @public
587
+ * @see [CLI option](../#-timeout-ms-t-ms)
588
+ * @see [Timeouts](../#timeouts)
589
+ * @param {number|string} msecs - Timeout threshold value.
590
+ * @return {Mocha} this
591
+ * @chainable
592
+ * @example
593
+ *
594
+ * // Sets timeout to one second
595
+ * mocha.timeout(1000);
596
+ * @example
597
+ *
598
+ * // Same as above but using string argument
599
+ * mocha.timeout('1s');
600
+ */
601
+ Mocha.prototype.timeout = function(msecs) {
602
+ this.suite.timeout(msecs);
603
+ return this;
604
+ };
605
+ /**
606
+ * Sets the number of times to retry failed tests.
607
+ *
608
+ * @public
609
+ * @see [CLI option](../#-retries-n)
610
+ * @see [Retry Tests](../#retry-tests)
611
+ * @param {number} retry - Number of times to retry failed tests.
612
+ * @return {Mocha} this
613
+ * @chainable
614
+ * @example
615
+ *
616
+ * // Allow any failed test to retry one more time
617
+ * mocha.retries(1);
618
+ */
619
+ Mocha.prototype.retries = function(retry) {
620
+ this.suite.retries(retry);
621
+ return this;
622
+ };
623
+ /**
624
+ * Sets slowness threshold value.
625
+ *
626
+ * @public
627
+ * @see [CLI option](../#-slow-ms-s-ms)
628
+ * @param {number} msecs - Slowness threshold value.
629
+ * @return {Mocha} this
630
+ * @chainable
631
+ * @example
632
+ *
633
+ * // Sets "slow" threshold to half a second
634
+ * mocha.slow(500);
635
+ * @example
636
+ *
637
+ * // Same as above but using string argument
638
+ * mocha.slow('0.5s');
639
+ */
640
+ Mocha.prototype.slow = function(msecs) {
641
+ this.suite.slow(msecs);
642
+ return this;
643
+ };
644
+ /**
645
+ * Forces all tests to either accept a `done` callback or return a promise.
646
+ *
647
+ * @public
648
+ * @see [CLI option](../#-async-only-a)
649
+ * @param {boolean} [asyncOnly=true] - Whether to force `done` callback or promise.
650
+ * @return {Mocha} this
651
+ * @chainable
652
+ */
653
+ Mocha.prototype.asyncOnly = function(asyncOnly) {
654
+ this.options.asyncOnly = asyncOnly !== false;
655
+ return this;
656
+ };
657
+ /**
658
+ * Disables syntax highlighting (in browser).
659
+ *
660
+ * @public
661
+ * @return {Mocha} this
662
+ * @chainable
663
+ */
664
+ Mocha.prototype.noHighlighting = function() {
665
+ this.options.noHighlighting = true;
666
+ return this;
667
+ };
668
+ /**
669
+ * Enables or disables uncaught errors to propagate.
670
+ *
671
+ * @public
672
+ * @see [CLI option](../#-allow-uncaught)
673
+ * @param {boolean} [allowUncaught=true] - Whether to propagate uncaught errors.
674
+ * @return {Mocha} this
675
+ * @chainable
676
+ */
677
+ Mocha.prototype.allowUncaught = function(allowUncaught) {
678
+ this.options.allowUncaught = allowUncaught !== false;
679
+ return this;
680
+ };
681
+ /**
682
+ * @summary
683
+ * Delays root suite execution.
684
+ *
685
+ * @description
686
+ * Used to perform async operations before any suites are run.
687
+ *
688
+ * @public
689
+ * @see [delayed root suite](../#delayed-root-suite)
690
+ * @returns {Mocha} this
691
+ * @chainable
692
+ */
693
+ Mocha.prototype.delay = function delay() {
694
+ this.options.delay = true;
695
+ return this;
696
+ };
697
+ /**
698
+ * Enables or disables running tests in dry-run mode.
699
+ *
700
+ * @public
701
+ * @see [CLI option](../#-dry-run)
702
+ * @param {boolean} [dryRun=true] - Whether to activate dry-run mode.
703
+ * @return {Mocha} this
704
+ * @chainable
705
+ */
706
+ Mocha.prototype.dryRun = function(dryRun) {
707
+ this.options.dryRun = dryRun !== false;
708
+ return this;
709
+ };
710
+ /**
711
+ * Fails test run if no tests encountered with exit-code 1.
712
+ *
713
+ * @public
714
+ * @see [CLI option](../#-fail-zero)
715
+ * @param {boolean} [failZero=true] - Whether to fail test run.
716
+ * @return {Mocha} this
717
+ * @chainable
718
+ */
719
+ Mocha.prototype.failZero = function(failZero) {
720
+ this.options.failZero = failZero !== false;
721
+ return this;
722
+ };
723
+ /**
724
+ * Fail test run if tests were failed.
725
+ *
726
+ * @public
727
+ * @see [CLI option](../#-pass-on-failing-test-suite)
728
+ * @param {boolean} [passOnFailingTestSuite=false] - Whether to fail test run.
729
+ * @return {Mocha} this
730
+ * @chainable
731
+ */
732
+ Mocha.prototype.passOnFailingTestSuite = function(passOnFailingTestSuite) {
733
+ this.options.passOnFailingTestSuite = passOnFailingTestSuite === true;
734
+ return this;
735
+ };
736
+ /**
737
+ * Causes tests marked `only` to fail the suite.
738
+ *
739
+ * @public
740
+ * @see [CLI option](../#-forbid-only)
741
+ * @param {boolean} [forbidOnly=true] - Whether tests marked `only` fail the suite.
742
+ * @returns {Mocha} this
743
+ * @chainable
744
+ */
745
+ Mocha.prototype.forbidOnly = function(forbidOnly) {
746
+ this.options.forbidOnly = forbidOnly !== false;
747
+ return this;
748
+ };
749
+ /**
750
+ * Causes pending tests and tests marked `skip` to fail the suite.
751
+ *
752
+ * @public
753
+ * @see [CLI option](../#-forbid-pending)
754
+ * @param {boolean} [forbidPending=true] - Whether pending tests fail the suite.
755
+ * @returns {Mocha} this
756
+ * @chainable
757
+ */
758
+ Mocha.prototype.forbidPending = function(forbidPending) {
759
+ this.options.forbidPending = forbidPending !== false;
760
+ return this;
761
+ };
762
+ /**
763
+ * Throws an error if mocha is in the wrong state to be able to transition to a "running" state.
764
+ * @private
765
+ */
766
+ Mocha.prototype._guardRunningStateTransition = function() {
767
+ if (this._state === mochaStates.RUNNING) throw createMochaInstanceAlreadyRunningError("Mocha instance is currently running tests, cannot start a next test run until this one is done", this);
768
+ if (this._state === mochaStates.DISPOSED || this._state === mochaStates.REFERENCES_CLEANED) throw createMochaInstanceAlreadyDisposedError("Mocha instance is already disposed, cannot start a new test run. Please create a new mocha instance. Be sure to set disable `cleanReferencesAfterRun` when you want to reuse the same mocha instance for multiple test runs.", this._cleanReferencesAfterRun, this);
769
+ };
770
+ /**
771
+ * Mocha version as specified by "package.json".
772
+ *
773
+ * @name Mocha#version
774
+ * @type string
775
+ * @readonly
776
+ */
777
+ Object.defineProperty(Mocha.prototype, "version", {
778
+ value: require_package().version,
779
+ configurable: false,
780
+ enumerable: true,
781
+ writable: false
782
+ });
783
+ /**
784
+ * Runs root suite and invokes `fn()` when complete.
785
+ *
786
+ * @description
787
+ * To run tests multiple times (or to run tests in files that are
788
+ * already in the `require` cache), make sure to clear them from
789
+ * the cache first!
790
+ *
791
+ * @public
792
+ * @see {@link Mocha#unloadFiles}
793
+ * @see {@link Runner#run}
794
+ * @param {DoneCB} [fn] - Callback invoked when test execution completed.
795
+ * @returns {import("./runner.js")} runner instance
796
+ * @example
797
+ *
798
+ * // exit with non-zero status if there were test failures
799
+ * mocha.run(failures => process.exitCode = failures ? 1 : 0);
800
+ */
801
+ Mocha.prototype.run = function(fn) {
802
+ this._guardRunningStateTransition();
803
+ this._state = mochaStates.RUNNING;
804
+ if (this._previousRunner) {
805
+ this._previousRunner.dispose();
806
+ this.suite.reset();
807
+ }
808
+ if (this.files.length && !this._lazyLoadFiles) this.loadFiles();
809
+ var suite = this.suite;
810
+ var options = this.options;
811
+ options.files = this.files;
812
+ const runner = new this._runnerClass(suite, {
813
+ cleanReferencesAfterRun: this._cleanReferencesAfterRun,
814
+ delay: options.delay,
815
+ dryRun: options.dryRun,
816
+ failZero: options.failZero
817
+ });
818
+ createStatsCollector(runner);
819
+ var reporter = new this._reporter(runner, options);
820
+ runner.checkLeaks = options.checkLeaks === true;
821
+ runner.fullStackTrace = options.fullTrace;
822
+ runner.asyncOnly = options.asyncOnly;
823
+ runner.allowUncaught = options.allowUncaught;
824
+ runner.forbidOnly = options.forbidOnly;
825
+ runner.forbidPending = options.forbidPending;
826
+ if (options.grep) runner.grep(options.grep, options.invert);
827
+ if (options.global) runner.globals(options.global);
828
+ if (options.color !== void 0) exports.reporters.Base.useColors = options.color;
829
+ exports.reporters.Base.inlineDiffs = options.inlineDiffs;
830
+ exports.reporters.Base.hideDiff = !options.diff;
831
+ const done = (failures) => {
832
+ this._previousRunner = runner;
833
+ this._state = this._cleanReferencesAfterRun ? mochaStates.REFERENCES_CLEANED : mochaStates.INIT;
834
+ fn = fn || utils.noop;
835
+ if (typeof reporter.done === "function") reporter.done(failures, fn);
836
+ else fn(failures);
837
+ };
838
+ const runAsync = async (runner$1) => {
839
+ const context = this.options.enableGlobalSetup && this.hasGlobalSetupFixtures() ? await this.runGlobalSetup(runner$1) : {};
840
+ const failureCount = await runner$1.runAsync({
841
+ files: this.files,
842
+ options
843
+ });
844
+ if (this.options.enableGlobalTeardown && this.hasGlobalTeardownFixtures()) await this.runGlobalTeardown(runner$1, { context });
845
+ return failureCount;
846
+ };
847
+ runAsync(runner).then(done);
848
+ return runner;
849
+ };
850
+ /**
851
+ * Assigns hooks to the root suite
852
+ * @param {MochaRootHookObject} [hooks] - Hooks to assign to root suite
853
+ * @chainable
854
+ */
855
+ Mocha.prototype.rootHooks = function rootHooks({ beforeAll = [], beforeEach = [], afterAll = [], afterEach = [] } = {}) {
856
+ beforeAll = utils.castArray(beforeAll);
857
+ beforeEach = utils.castArray(beforeEach);
858
+ afterAll = utils.castArray(afterAll);
859
+ afterEach = utils.castArray(afterEach);
860
+ beforeAll.forEach((hook) => {
861
+ this.suite.beforeAll(hook);
862
+ });
863
+ beforeEach.forEach((hook) => {
864
+ this.suite.beforeEach(hook);
865
+ });
866
+ afterAll.forEach((hook) => {
867
+ this.suite.afterAll(hook);
868
+ });
869
+ afterEach.forEach((hook) => {
870
+ this.suite.afterEach(hook);
871
+ });
872
+ return this;
873
+ };
874
+ /**
875
+ * Toggles parallel mode.
876
+ *
877
+ * Must be run before calling {@link Mocha#run}. Changes the `Runner` class to
878
+ * use; also enables lazy file loading if not already done so.
879
+ *
880
+ * Warning: when passed `false` and lazy loading has been enabled _via any means_ (including calling `parallelMode(true)`), this method will _not_ disable lazy loading. Lazy loading is a prerequisite for parallel
881
+ * mode, but parallel mode is _not_ a prerequisite for lazy loading!
882
+ * @param {boolean} [enable] - If `true`, enable; otherwise disable.
883
+ * @throws If run in browser
884
+ * @throws If Mocha not in `INIT` state
885
+ * @returns {Mocha}
886
+ * @chainable
887
+ * @public
888
+ */
889
+ Mocha.prototype.parallelMode = function parallelMode(enable = true) {
890
+ if (utils.isBrowser()) throw createUnsupportedError("parallel mode is only supported in Node.js");
891
+ const parallel = Boolean(enable);
892
+ if (parallel === this.options.parallel && this._lazyLoadFiles && this._runnerClass !== exports.Runner) return this;
893
+ if (this._state !== mochaStates.INIT) throw createUnsupportedError("cannot change parallel mode after having called run()");
894
+ this.options.parallel = parallel;
895
+ this._runnerClass = parallel ? require_parallel_buffered_runner() : exports.Runner;
896
+ return this.lazyLoadFiles(this._lazyLoadFiles || parallel);
897
+ };
898
+ /**
899
+ * Disables implicit call to {@link Mocha#loadFiles} in {@link Mocha#run}. This
900
+ * setting is used by watch mode, parallel mode, and for loading ESM files.
901
+ * @todo This should throw if we've already loaded files; such behavior
902
+ * necessitates adding a new state.
903
+ * @param {boolean} [enable] - If `true`, disable eager loading of files in
904
+ * {@link Mocha#run}
905
+ * @chainable
906
+ * @public
907
+ */
908
+ Mocha.prototype.lazyLoadFiles = function lazyLoadFiles(enable) {
909
+ this._lazyLoadFiles = enable === true;
910
+ debug("set lazy load to %s", enable);
911
+ return this;
912
+ };
913
+ /**
914
+ * Configures one or more global setup fixtures.
915
+ *
916
+ * If given no parameters, _unsets_ any previously-set fixtures.
917
+ * @chainable
918
+ * @public
919
+ * @param {MochaGlobalFixture|MochaGlobalFixture[]} [setupFns] - Global setup fixture(s)
920
+ * @returns {Mocha}
921
+ */
922
+ Mocha.prototype.globalSetup = function globalSetup(setupFns = []) {
923
+ setupFns = utils.castArray(setupFns);
924
+ this.options.globalSetup = setupFns;
925
+ debug("configured %d global setup functions", setupFns.length);
926
+ return this;
927
+ };
928
+ /**
929
+ * Configures one or more global teardown fixtures.
930
+ *
931
+ * If given no parameters, _unsets_ any previously-set fixtures.
932
+ * @chainable
933
+ * @public
934
+ * @param {MochaGlobalFixture|MochaGlobalFixture[]} [teardownFns] - Global teardown fixture(s)
935
+ * @returns {Mocha}
936
+ */
937
+ Mocha.prototype.globalTeardown = function globalTeardown(teardownFns = []) {
938
+ teardownFns = utils.castArray(teardownFns);
939
+ this.options.globalTeardown = teardownFns;
940
+ debug("configured %d global teardown functions", teardownFns.length);
941
+ return this;
942
+ };
943
+ /**
944
+ * Run any global setup fixtures sequentially, if any.
945
+ *
946
+ * This is _automatically called_ by {@link Mocha#run} _unless_ the `runGlobalSetup` option is `false`; see {@link Mocha#enableGlobalSetup}.
947
+ *
948
+ * The context object this function resolves with should be consumed by {@link Mocha#runGlobalTeardown}.
949
+ * @param {object} [context] - Context object if already have one
950
+ * @public
951
+ * @returns {Promise<object>} Context object
952
+ */
953
+ Mocha.prototype.runGlobalSetup = async function runGlobalSetup(context = {}) {
954
+ const { globalSetup } = this.options;
955
+ if (globalSetup && globalSetup.length) {
956
+ debug("run(): global setup starting");
957
+ await this._runGlobalFixtures(globalSetup, context);
958
+ debug("run(): global setup complete");
959
+ }
960
+ return context;
961
+ };
962
+ /**
963
+ * Run any global teardown fixtures sequentially, if any.
964
+ *
965
+ * This is _automatically called_ by {@link Mocha#run} _unless_ the `runGlobalTeardown` option is `false`; see {@link Mocha#enableGlobalTeardown}.
966
+ *
967
+ * Should be called with context object returned by {@link Mocha#runGlobalSetup}, if applicable.
968
+ * @param {object} [context] - Context object if already have one
969
+ * @public
970
+ * @returns {Promise<object>} Context object
971
+ */
972
+ Mocha.prototype.runGlobalTeardown = async function runGlobalTeardown(context = {}) {
973
+ const { globalTeardown } = this.options;
974
+ if (globalTeardown && globalTeardown.length) {
975
+ debug("run(): global teardown starting");
976
+ await this._runGlobalFixtures(globalTeardown, context);
977
+ }
978
+ debug("run(): global teardown complete");
979
+ return context;
980
+ };
981
+ /**
982
+ * Run global fixtures sequentially with context `context`
983
+ * @private
984
+ * @param {MochaGlobalFixture[]} [fixtureFns] - Fixtures to run
985
+ * @param {object} [context] - context object
986
+ * @returns {Promise<object>} context object
987
+ */
988
+ Mocha.prototype._runGlobalFixtures = async function _runGlobalFixtures(fixtureFns = [], context = {}) {
989
+ for await (const fixtureFn of fixtureFns) await fixtureFn.call(context);
990
+ return context;
991
+ };
992
+ /**
993
+ * Toggle execution of any global setup fixture(s)
994
+ *
995
+ * @chainable
996
+ * @public
997
+ * @param {boolean } [enabled=true] - If `false`, do not run global setup fixture
998
+ * @returns {Mocha}
999
+ */
1000
+ Mocha.prototype.enableGlobalSetup = function enableGlobalSetup(enabled = true) {
1001
+ this.options.enableGlobalSetup = Boolean(enabled);
1002
+ return this;
1003
+ };
1004
+ /**
1005
+ * Toggle execution of any global teardown fixture(s)
1006
+ *
1007
+ * @chainable
1008
+ * @public
1009
+ * @param {boolean } [enabled=true] - If `false`, do not run global teardown fixture
1010
+ * @returns {Mocha}
1011
+ */
1012
+ Mocha.prototype.enableGlobalTeardown = function enableGlobalTeardown(enabled = true) {
1013
+ this.options.enableGlobalTeardown = Boolean(enabled);
1014
+ return this;
1015
+ };
1016
+ /**
1017
+ * Returns `true` if one or more global setup fixtures have been supplied.
1018
+ * @public
1019
+ * @returns {boolean}
1020
+ */
1021
+ Mocha.prototype.hasGlobalSetupFixtures = function hasGlobalSetupFixtures() {
1022
+ return Boolean(this.options.globalSetup.length);
1023
+ };
1024
+ /**
1025
+ * Returns `true` if one or more global teardown fixtures have been supplied.
1026
+ * @public
1027
+ * @returns {boolean}
1028
+ */
1029
+ Mocha.prototype.hasGlobalTeardownFixtures = function hasGlobalTeardownFixtures() {
1030
+ return Boolean(this.options.globalTeardown.length);
1031
+ };
1032
+ }) });
1033
+
1034
+ //#endregion
1035
+ export default require_mocha();
1036
+
1037
+ export { require_mocha };