@eggjs/mock 6.0.6 → 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 -171
  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 -171
  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 -510
  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,72 @@
1
+ import { __commonJS } from "../../../../../../_virtual/rolldown_runtime.js";
2
+ import { require_runner } from "./runner.js";
3
+
4
+ //#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js
5
+ var require_stats_collector = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js": ((exports, module) => {
6
+ /**
7
+ * @typedef {import('./types.d.ts').StatsCollector} StatsCollector
8
+ * @typedef {import('./runner.js')} Runner
9
+ */
10
+ /**
11
+ * Provides a factory function for a {@link StatsCollector} object.
12
+ * @module
13
+ */
14
+ var constants = require_runner().constants;
15
+ var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
16
+ var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
17
+ var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
18
+ var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
19
+ var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
20
+ var EVENT_RUN_END = constants.EVENT_RUN_END;
21
+ var EVENT_TEST_END = constants.EVENT_TEST_END;
22
+ var Date = global.Date;
23
+ /**
24
+ * Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`.
25
+ *
26
+ * @private
27
+ * @param {Runner} runner - Runner instance
28
+ * @throws {TypeError} If falsy `runner`
29
+ */
30
+ function createStatsCollector(runner) {
31
+ /**
32
+ * @type {StatsCollector}
33
+ */
34
+ var stats = {
35
+ suites: 0,
36
+ tests: 0,
37
+ passes: 0,
38
+ pending: 0,
39
+ failures: 0
40
+ };
41
+ if (!runner) throw new TypeError("Missing runner argument");
42
+ runner.stats = stats;
43
+ runner.once(EVENT_RUN_BEGIN, function() {
44
+ stats.start = new Date();
45
+ });
46
+ runner.on(EVENT_SUITE_BEGIN, function(suite) {
47
+ suite.root || stats.suites++;
48
+ });
49
+ runner.on(EVENT_TEST_PASS, function() {
50
+ stats.passes++;
51
+ });
52
+ runner.on(EVENT_TEST_FAIL, function() {
53
+ stats.failures++;
54
+ });
55
+ runner.on(EVENT_TEST_PENDING, function() {
56
+ stats.pending++;
57
+ });
58
+ runner.on(EVENT_TEST_END, function() {
59
+ stats.tests++;
60
+ });
61
+ runner.once(EVENT_RUN_END, function() {
62
+ stats.end = new Date();
63
+ stats.duration = stats.end - stats.start;
64
+ });
65
+ }
66
+ module.exports = createStatsCollector;
67
+ }) });
68
+
69
+ //#endregion
70
+ export default require_stats_collector();
71
+
72
+ export { require_stats_collector };
@@ -0,0 +1,517 @@
1
+ import { __commonJS, __require } from "../../../../../../_virtual/rolldown_runtime.js";
2
+ import { require_ms } from "../../../../ms@2.1.3/node_modules/ms/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_hook } from "./hook.js";
7
+
8
+ //#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js
9
+ var require_suite = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js": ((exports, module) => {
10
+ /**
11
+ * @typedef {import('./test.js')} Test
12
+ */
13
+ /**
14
+ * Module dependencies.
15
+ * @private
16
+ */
17
+ const { EventEmitter } = __require("node:events");
18
+ const Hook = require_hook();
19
+ var { assignNewMochaID, clamp, constants: utilsConstants, defineConstants, getMochaID, inherits, isString } = require_utils();
20
+ const debug = require_src()("mocha:suite");
21
+ const milliseconds = require_ms();
22
+ const errors = require_errors();
23
+ const { MOCHA_ID_PROP_NAME } = utilsConstants;
24
+ /**
25
+ * Expose `Suite`.
26
+ */
27
+ exports = module.exports = Suite;
28
+ /**
29
+ * Create a new `Suite` with the given `title` and parent `Suite`.
30
+ *
31
+ * @public
32
+ * @param {Suite} parent - Parent suite (required!)
33
+ * @param {string} title - Title
34
+ * @return {Suite}
35
+ */
36
+ Suite.create = function(parent, title) {
37
+ var suite = new Suite(title, parent.ctx);
38
+ suite.parent = parent;
39
+ title = suite.fullTitle();
40
+ parent.addSuite(suite);
41
+ return suite;
42
+ };
43
+ /**
44
+ * Constructs a new `Suite` instance with the given `title`, `ctx`, and `isRoot`.
45
+ *
46
+ * @public
47
+ * @class
48
+ * @extends EventEmitter
49
+ * @see {@link https://nodejs.org/api/events.html#events_class_eventemitter|EventEmitter}
50
+ * @param {string} title - Suite title.
51
+ * @param {Context} parentContext - Parent context instance.
52
+ * @param {boolean} [isRoot=false] - Whether this is the root suite.
53
+ */
54
+ function Suite(title, parentContext, isRoot) {
55
+ if (!isString(title)) throw errors.createInvalidArgumentTypeError("Suite argument \"title\" must be a string. Received type \"" + typeof title + "\"", "title", "string");
56
+ this.title = title;
57
+ function Context() {}
58
+ Context.prototype = parentContext;
59
+ this.ctx = new Context();
60
+ this.suites = [];
61
+ this.tests = [];
62
+ this.root = isRoot === true;
63
+ this.pending = false;
64
+ this._retries = -1;
65
+ this._beforeEach = [];
66
+ this._beforeAll = [];
67
+ this._afterEach = [];
68
+ this._afterAll = [];
69
+ this._timeout = 2e3;
70
+ this._slow = 75;
71
+ this._bail = false;
72
+ this._onlyTests = [];
73
+ this._onlySuites = [];
74
+ assignNewMochaID(this);
75
+ Object.defineProperty(this, "id", { get() {
76
+ return getMochaID(this);
77
+ } });
78
+ this.reset();
79
+ }
80
+ /**
81
+ * Inherit from `EventEmitter.prototype`.
82
+ */
83
+ inherits(Suite, EventEmitter);
84
+ /**
85
+ * Resets the state initially or for a next run.
86
+ */
87
+ Suite.prototype.reset = function() {
88
+ this.delayed = false;
89
+ function doReset(thingToReset) {
90
+ thingToReset.reset();
91
+ }
92
+ this.suites.forEach(doReset);
93
+ this.tests.forEach(doReset);
94
+ this._beforeEach.forEach(doReset);
95
+ this._afterEach.forEach(doReset);
96
+ this._beforeAll.forEach(doReset);
97
+ this._afterAll.forEach(doReset);
98
+ };
99
+ /**
100
+ * Return a clone of this `Suite`.
101
+ *
102
+ * @private
103
+ * @return {Suite}
104
+ */
105
+ Suite.prototype.clone = function() {
106
+ var suite = new Suite(this.title);
107
+ debug("clone");
108
+ suite.ctx = this.ctx;
109
+ suite.root = this.root;
110
+ suite.timeout(this.timeout());
111
+ suite.retries(this.retries());
112
+ suite.slow(this.slow());
113
+ suite.bail(this.bail());
114
+ return suite;
115
+ };
116
+ /**
117
+ * Set or get timeout `ms` or short-hand such as "2s".
118
+ *
119
+ * @private
120
+ * @todo Do not attempt to set value if `ms` is undefined
121
+ * @param {number|string} ms
122
+ * @return {Suite|number} for chaining
123
+ */
124
+ Suite.prototype.timeout = function(ms) {
125
+ if (!arguments.length) return this._timeout;
126
+ if (typeof ms === "string") ms = milliseconds(ms);
127
+ var range = [0, Math.pow(2, 31) - 1];
128
+ ms = clamp(ms, range);
129
+ debug("timeout %d", ms);
130
+ this._timeout = parseInt(ms, 10);
131
+ return this;
132
+ };
133
+ /**
134
+ * Set or get number of times to retry a failed test.
135
+ *
136
+ * @private
137
+ * @param {number|string} n
138
+ * @return {Suite|number} for chaining
139
+ */
140
+ Suite.prototype.retries = function(n) {
141
+ if (!arguments.length) return this._retries;
142
+ debug("retries %d", n);
143
+ this._retries = parseInt(n, 10) || 0;
144
+ return this;
145
+ };
146
+ /**
147
+ * Set or get slow `ms` or short-hand such as "2s".
148
+ *
149
+ * @private
150
+ * @param {number|string} ms
151
+ * @return {Suite|number} for chaining
152
+ */
153
+ Suite.prototype.slow = function(ms) {
154
+ if (!arguments.length) return this._slow;
155
+ if (typeof ms === "string") ms = milliseconds(ms);
156
+ debug("slow %d", ms);
157
+ this._slow = ms;
158
+ return this;
159
+ };
160
+ /**
161
+ * Set or get whether to bail after first error.
162
+ *
163
+ * @private
164
+ * @param {boolean} bail
165
+ * @return {Suite|number} for chaining
166
+ */
167
+ Suite.prototype.bail = function(bail) {
168
+ if (!arguments.length) return this._bail;
169
+ debug("bail %s", bail);
170
+ this._bail = bail;
171
+ return this;
172
+ };
173
+ /**
174
+ * Check if this suite or its parent suite is marked as pending.
175
+ *
176
+ * @private
177
+ */
178
+ Suite.prototype.isPending = function() {
179
+ return this.pending || this.parent && this.parent.isPending();
180
+ };
181
+ /**
182
+ * Generic hook-creator.
183
+ * @private
184
+ * @param {string} title - Title of hook
185
+ * @param {Function} fn - Hook callback
186
+ * @returns {Hook} A new hook
187
+ */
188
+ Suite.prototype._createHook = function(title, fn) {
189
+ var hook = new Hook(title, fn);
190
+ hook.parent = this;
191
+ hook.timeout(this.timeout());
192
+ hook.retries(this.retries());
193
+ hook.slow(this.slow());
194
+ hook.ctx = this.ctx;
195
+ hook.file = this.file;
196
+ return hook;
197
+ };
198
+ /**
199
+ * Run `fn(test[, done])` before running tests.
200
+ *
201
+ * @private
202
+ * @param {string} title
203
+ * @param {Function} fn
204
+ * @return {Suite} for chaining
205
+ */
206
+ Suite.prototype.beforeAll = function(title, fn) {
207
+ if (this.isPending()) return this;
208
+ if (typeof title === "function") {
209
+ fn = title;
210
+ title = fn.name;
211
+ }
212
+ title = "\"before all\" hook" + (title ? ": " + title : "");
213
+ var hook = this._createHook(title, fn);
214
+ this._beforeAll.push(hook);
215
+ this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_ALL, hook);
216
+ return hook;
217
+ };
218
+ /**
219
+ * Run `fn(test[, done])` after running tests.
220
+ *
221
+ * @private
222
+ * @param {string} title
223
+ * @param {Function} fn
224
+ * @return {Suite} for chaining
225
+ */
226
+ Suite.prototype.afterAll = function(title, fn) {
227
+ if (this.isPending()) return this;
228
+ if (typeof title === "function") {
229
+ fn = title;
230
+ title = fn.name;
231
+ }
232
+ title = "\"after all\" hook" + (title ? ": " + title : "");
233
+ var hook = this._createHook(title, fn);
234
+ this._afterAll.push(hook);
235
+ this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_ALL, hook);
236
+ return hook;
237
+ };
238
+ /**
239
+ * Run `fn(test[, done])` before each test case.
240
+ *
241
+ * @private
242
+ * @param {string} title
243
+ * @param {Function} fn
244
+ * @return {Suite} for chaining
245
+ */
246
+ Suite.prototype.beforeEach = function(title, fn) {
247
+ if (this.isPending()) return this;
248
+ if (typeof title === "function") {
249
+ fn = title;
250
+ title = fn.name;
251
+ }
252
+ title = "\"before each\" hook" + (title ? ": " + title : "");
253
+ var hook = this._createHook(title, fn);
254
+ this._beforeEach.push(hook);
255
+ this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_EACH, hook);
256
+ return hook;
257
+ };
258
+ /**
259
+ * Run `fn(test[, done])` after each test case.
260
+ *
261
+ * @private
262
+ * @param {string} title
263
+ * @param {Function} fn
264
+ * @return {Suite} for chaining
265
+ */
266
+ Suite.prototype.afterEach = function(title, fn) {
267
+ if (this.isPending()) return this;
268
+ if (typeof title === "function") {
269
+ fn = title;
270
+ title = fn.name;
271
+ }
272
+ title = "\"after each\" hook" + (title ? ": " + title : "");
273
+ var hook = this._createHook(title, fn);
274
+ this._afterEach.push(hook);
275
+ this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_EACH, hook);
276
+ return hook;
277
+ };
278
+ /**
279
+ * Add a test `suite`.
280
+ *
281
+ * @private
282
+ * @param {Suite} suite
283
+ * @return {Suite} for chaining
284
+ */
285
+ Suite.prototype.addSuite = function(suite) {
286
+ suite.parent = this;
287
+ suite.root = false;
288
+ suite.timeout(this.timeout());
289
+ suite.retries(this.retries());
290
+ suite.slow(this.slow());
291
+ suite.bail(this.bail());
292
+ this.suites.push(suite);
293
+ this.emit(constants.EVENT_SUITE_ADD_SUITE, suite);
294
+ return this;
295
+ };
296
+ /**
297
+ * Add a `test` to this suite.
298
+ *
299
+ * @private
300
+ * @param {Test} test
301
+ * @return {Suite} for chaining
302
+ */
303
+ Suite.prototype.addTest = function(test) {
304
+ test.parent = this;
305
+ test.timeout(this.timeout());
306
+ test.retries(this.retries());
307
+ test.slow(this.slow());
308
+ test.ctx = this.ctx;
309
+ this.tests.push(test);
310
+ this.emit(constants.EVENT_SUITE_ADD_TEST, test);
311
+ return this;
312
+ };
313
+ /**
314
+ * Return the full title generated by recursively concatenating the parent's
315
+ * full title.
316
+ *
317
+ * @memberof Suite
318
+ * @public
319
+ * @return {string}
320
+ */
321
+ Suite.prototype.fullTitle = function() {
322
+ return this.titlePath().join(" ");
323
+ };
324
+ /**
325
+ * Return the title path generated by recursively concatenating the parent's
326
+ * title path.
327
+ *
328
+ * @memberof Suite
329
+ * @public
330
+ * @return {string[]}
331
+ */
332
+ Suite.prototype.titlePath = function() {
333
+ var result = [];
334
+ if (this.parent) result = result.concat(this.parent.titlePath());
335
+ if (!this.root) result.push(this.title);
336
+ return result;
337
+ };
338
+ /**
339
+ * Return the total number of tests.
340
+ *
341
+ * @memberof Suite
342
+ * @public
343
+ * @return {number}
344
+ */
345
+ Suite.prototype.total = function() {
346
+ return this.suites.reduce(function(sum, suite) {
347
+ return sum + suite.total();
348
+ }, 0) + this.tests.length;
349
+ };
350
+ /**
351
+ * Iterates through each suite recursively to find all tests. Applies a
352
+ * function in the format `fn(test)`.
353
+ *
354
+ * @private
355
+ * @param {Function} fn
356
+ * @return {Suite}
357
+ */
358
+ Suite.prototype.eachTest = function(fn) {
359
+ this.tests.forEach(fn);
360
+ this.suites.forEach(function(suite) {
361
+ suite.eachTest(fn);
362
+ });
363
+ return this;
364
+ };
365
+ /**
366
+ * This will run the root suite if we happen to be running in delayed mode.
367
+ * @private
368
+ */
369
+ Suite.prototype.run = function run() {
370
+ if (this.root) this.emit(constants.EVENT_ROOT_SUITE_RUN);
371
+ };
372
+ /**
373
+ * Determines whether a suite has an `only` test or suite as a descendant.
374
+ *
375
+ * @private
376
+ * @returns {Boolean}
377
+ */
378
+ Suite.prototype.hasOnly = function hasOnly() {
379
+ return this._onlyTests.length > 0 || this._onlySuites.length > 0 || this.suites.some(function(suite) {
380
+ return suite.hasOnly();
381
+ });
382
+ };
383
+ /**
384
+ * Filter suites based on `isOnly` logic.
385
+ *
386
+ * @private
387
+ * @returns {Boolean}
388
+ */
389
+ Suite.prototype.filterOnly = function filterOnly() {
390
+ if (this._onlyTests.length) {
391
+ this.tests = this._onlyTests;
392
+ this.suites = [];
393
+ } else {
394
+ this.tests = [];
395
+ this._onlySuites.forEach(function(onlySuite) {
396
+ if (onlySuite.hasOnly()) onlySuite.filterOnly();
397
+ });
398
+ var onlySuites = this._onlySuites;
399
+ this.suites = this.suites.filter(function(childSuite) {
400
+ return onlySuites.indexOf(childSuite) !== -1 || childSuite.filterOnly();
401
+ });
402
+ }
403
+ return this.tests.length > 0 || this.suites.length > 0;
404
+ };
405
+ /**
406
+ * Adds a suite to the list of subsuites marked `only`.
407
+ *
408
+ * @private
409
+ * @param {Suite} suite
410
+ */
411
+ Suite.prototype.appendOnlySuite = function(suite) {
412
+ this._onlySuites.push(suite);
413
+ };
414
+ /**
415
+ * Marks a suite to be `only`.
416
+ *
417
+ * @private
418
+ */
419
+ Suite.prototype.markOnly = function() {
420
+ this.parent && this.parent.appendOnlySuite(this);
421
+ };
422
+ /**
423
+ * Adds a test to the list of tests marked `only`.
424
+ *
425
+ * @private
426
+ * @param {Test} test
427
+ */
428
+ Suite.prototype.appendOnlyTest = function(test) {
429
+ this._onlyTests.push(test);
430
+ };
431
+ /**
432
+ * Returns the array of hooks by hook name; see `HOOK_TYPE_*` constants.
433
+ * @private
434
+ */
435
+ Suite.prototype.getHooks = function getHooks(name) {
436
+ return this["_" + name];
437
+ };
438
+ /**
439
+ * cleans all references from this suite and all child suites.
440
+ */
441
+ Suite.prototype.dispose = function() {
442
+ this.suites.forEach(function(suite) {
443
+ suite.dispose();
444
+ });
445
+ this.cleanReferences();
446
+ };
447
+ /**
448
+ * Cleans up the references to all the deferred functions
449
+ * (before/after/beforeEach/afterEach) and tests of a Suite.
450
+ * These must be deleted otherwise a memory leak can happen,
451
+ * as those functions may reference variables from closures,
452
+ * thus those variables can never be garbage collected as long
453
+ * as the deferred functions exist.
454
+ *
455
+ * @private
456
+ */
457
+ Suite.prototype.cleanReferences = function cleanReferences() {
458
+ function cleanArrReferences(arr) {
459
+ for (var i$1 = 0; i$1 < arr.length; i$1++) delete arr[i$1].fn;
460
+ }
461
+ if (Array.isArray(this._beforeAll)) cleanArrReferences(this._beforeAll);
462
+ if (Array.isArray(this._beforeEach)) cleanArrReferences(this._beforeEach);
463
+ if (Array.isArray(this._afterAll)) cleanArrReferences(this._afterAll);
464
+ if (Array.isArray(this._afterEach)) cleanArrReferences(this._afterEach);
465
+ for (var i = 0; i < this.tests.length; i++) delete this.tests[i].fn;
466
+ };
467
+ /**
468
+ * Returns an object suitable for IPC.
469
+ * Functions are represented by keys beginning with `$$`.
470
+ * @private
471
+ * @returns {Object}
472
+ */
473
+ Suite.prototype.serialize = function serialize() {
474
+ return {
475
+ _bail: this._bail,
476
+ $$fullTitle: this.fullTitle(),
477
+ $$isPending: Boolean(this.isPending()),
478
+ root: this.root,
479
+ title: this.title,
480
+ [MOCHA_ID_PROP_NAME]: this.id,
481
+ parent: this.parent ? { [MOCHA_ID_PROP_NAME]: this.parent.id } : null
482
+ };
483
+ };
484
+ var constants = defineConstants(
485
+ /**
486
+ * {@link Suite}-related constants.
487
+ * @public
488
+ * @memberof Suite
489
+ * @alias constants
490
+ * @readonly
491
+ * @static
492
+ * @enum {string}
493
+ */
494
+ {
495
+ EVENT_FILE_POST_REQUIRE: "post-require",
496
+ EVENT_FILE_PRE_REQUIRE: "pre-require",
497
+ EVENT_FILE_REQUIRE: "require",
498
+ EVENT_ROOT_SUITE_RUN: "run",
499
+ HOOK_TYPE_AFTER_ALL: "afterAll",
500
+ HOOK_TYPE_AFTER_EACH: "afterEach",
501
+ HOOK_TYPE_BEFORE_ALL: "beforeAll",
502
+ HOOK_TYPE_BEFORE_EACH: "beforeEach",
503
+ EVENT_SUITE_ADD_SUITE: "suite",
504
+ EVENT_SUITE_ADD_HOOK_AFTER_ALL: "afterAll",
505
+ EVENT_SUITE_ADD_HOOK_AFTER_EACH: "afterEach",
506
+ EVENT_SUITE_ADD_HOOK_BEFORE_ALL: "beforeAll",
507
+ EVENT_SUITE_ADD_HOOK_BEFORE_EACH: "beforeEach",
508
+ EVENT_SUITE_ADD_TEST: "test"
509
+ }
510
+ );
511
+ Suite.constants = constants;
512
+ }) });
513
+
514
+ //#endregion
515
+ export default require_suite();
516
+
517
+ export { require_suite };
@@ -0,0 +1,105 @@
1
+ import { __commonJS } from "../../../../../../_virtual/rolldown_runtime.js";
2
+ import { require_utils } from "./utils.js";
3
+ import { require_errors } from "./errors.js";
4
+ import { require_runnable } from "./runnable.js";
5
+
6
+ //#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js
7
+ var require_test = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js": ((exports, module) => {
8
+ var Runnable = require_runnable();
9
+ var utils = require_utils();
10
+ var createInvalidArgumentTypeError = require_errors().createInvalidArgumentTypeError;
11
+ var isString = utils.isString;
12
+ const { MOCHA_ID_PROP_NAME } = utils.constants;
13
+ module.exports = Test;
14
+ /**
15
+ * Initialize a new `Test` with the given `title` and callback `fn`.
16
+ *
17
+ * @public
18
+ * @class
19
+ * @extends Runnable
20
+ * @param {String} title - Test title (required)
21
+ * @param {Function} [fn] - Test callback. If omitted, the Test is considered "pending"
22
+ */
23
+ function Test(title, fn) {
24
+ if (!isString(title)) throw createInvalidArgumentTypeError("Test argument \"title\" should be a string. Received type \"" + typeof title + "\"", "title", "string");
25
+ this.type = "test";
26
+ Runnable.call(this, title, fn);
27
+ this.reset();
28
+ }
29
+ /**
30
+ * Inherit from `Runnable.prototype`.
31
+ */
32
+ utils.inherits(Test, Runnable);
33
+ /**
34
+ * Resets the state initially or for a next run.
35
+ */
36
+ Test.prototype.reset = function() {
37
+ Runnable.prototype.reset.call(this);
38
+ this.pending = !this.fn;
39
+ delete this.state;
40
+ };
41
+ /**
42
+ * Set or get retried test
43
+ *
44
+ * @private
45
+ */
46
+ Test.prototype.retriedTest = function(n) {
47
+ if (!arguments.length) return this._retriedTest;
48
+ this._retriedTest = n;
49
+ };
50
+ /**
51
+ * Add test to the list of tests marked `only`.
52
+ *
53
+ * @private
54
+ */
55
+ Test.prototype.markOnly = function() {
56
+ this.parent.appendOnlyTest(this);
57
+ };
58
+ Test.prototype.clone = function() {
59
+ var test = new Test(this.title, this.fn);
60
+ test.timeout(this.timeout());
61
+ test.slow(this.slow());
62
+ test.retries(this.retries());
63
+ test.currentRetry(this.currentRetry());
64
+ test.retriedTest(this.retriedTest() || this);
65
+ test.globals(this.globals());
66
+ test.parent = this.parent;
67
+ test.file = this.file;
68
+ test.ctx = this.ctx;
69
+ return test;
70
+ };
71
+ /**
72
+ * Returns an minimal object suitable for transmission over IPC.
73
+ * Functions are represented by keys beginning with `$$`.
74
+ * @private
75
+ * @returns {Object}
76
+ */
77
+ Test.prototype.serialize = function serialize() {
78
+ return {
79
+ $$currentRetry: this._currentRetry,
80
+ $$fullTitle: this.fullTitle(),
81
+ $$isPending: Boolean(this.pending),
82
+ $$retriedTest: this._retriedTest || null,
83
+ $$slow: this._slow,
84
+ $$titlePath: this.titlePath(),
85
+ body: this.body,
86
+ duration: this.duration,
87
+ err: this.err,
88
+ parent: {
89
+ $$fullTitle: this.parent.fullTitle(),
90
+ [MOCHA_ID_PROP_NAME]: this.parent.id
91
+ },
92
+ speed: this.speed,
93
+ state: this.state,
94
+ title: this.title,
95
+ type: this.type,
96
+ file: this.file,
97
+ [MOCHA_ID_PROP_NAME]: this.id
98
+ };
99
+ };
100
+ }) });
101
+
102
+ //#endregion
103
+ export default require_test();
104
+
105
+ export { require_test };