@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.
- package/README.md +35 -56
- package/README.zh_CN.md +30 -50
- package/dist/_virtual/rolldown_runtime.js +30 -0
- package/dist/app/extend/agent.d.ts +39 -0
- package/dist/app/extend/agent.js +48 -0
- package/dist/app/extend/application.d.ts +175 -0
- package/dist/app/extend/application.js +385 -0
- package/dist/app/middleware/cluster_app_mock.d.ts +6 -0
- package/dist/app/middleware/cluster_app_mock.js +97 -0
- package/dist/app.d.ts +10 -0
- package/dist/app.js +17 -0
- package/dist/bootstrap.d.ts +9 -0
- package/dist/bootstrap.js +14 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +47 -0
- package/dist/inject_mocha.d.ts +1 -0
- package/dist/inject_mocha.js +35 -0
- package/dist/lib/agent_handler.d.ts +7 -0
- package/dist/lib/agent_handler.js +26 -0
- package/dist/lib/app.d.ts +7 -0
- package/dist/lib/app.js +251 -0
- package/dist/lib/app_handler.d.ts +9 -0
- package/dist/lib/app_handler.js +56 -0
- package/dist/lib/cluster.d.ts +126 -0
- package/dist/lib/cluster.js +283 -0
- package/dist/lib/context.d.ts +4 -0
- package/dist/lib/context.js +12 -0
- package/dist/lib/format_options.d.ts +10 -0
- package/dist/lib/format_options.js +65 -0
- package/dist/lib/inject_context.d.ts +9 -0
- package/dist/lib/inject_context.js +106 -0
- package/dist/lib/mock_agent.d.ts +9 -0
- package/dist/lib/mock_agent.js +45 -0
- package/dist/lib/mock_custom_loader.d.ts +4 -0
- package/dist/lib/mock_custom_loader.js +35 -0
- package/dist/lib/mock_http_server.d.ts +6 -0
- package/dist/lib/mock_http_server.js +17 -0
- package/dist/lib/mock_httpclient.d.ts +40 -0
- package/dist/lib/mock_httpclient.js +110 -0
- package/dist/lib/parallel/agent.d.ts +24 -0
- package/dist/lib/parallel/agent.js +111 -0
- package/dist/lib/parallel/app.d.ts +24 -0
- package/dist/lib/parallel/app.js +99 -0
- package/dist/lib/parallel/util.d.ts +6 -0
- package/dist/lib/parallel/util.js +59 -0
- package/dist/lib/prerequire.d.ts +1 -0
- package/dist/lib/prerequire.js +1 -0
- package/dist/lib/request_call_function.d.ts +1 -0
- package/dist/lib/request_call_function.js +37 -0
- package/dist/lib/restore.d.ts +4 -0
- package/dist/lib/restore.js +16 -0
- package/dist/lib/start-cluster.d.ts +1 -0
- package/dist/lib/start-cluster.js +19 -0
- package/dist/lib/supertest.d.ts +16 -0
- package/dist/lib/supertest.js +39 -0
- package/dist/lib/tmp/empty.d.ts +1 -0
- package/dist/lib/tmp/empty.js +1 -0
- package/{src/lib/types.ts → dist/lib/types.d.ts} +12 -29
- package/dist/lib/types.js +1 -0
- package/dist/lib/utils.d.ts +12 -0
- package/dist/lib/utils.js +40 -0
- package/dist/node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js +142 -0
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js +157 -0
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js +97 -0
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js +40 -0
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js +814 -0
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js +50 -0
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js +68 -0
- package/dist/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js +752 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js +203 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js +209 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js +18 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js +215 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/dmp.js +24 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/xml.js +33 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/array.js +29 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/base.js +185 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/character.js +23 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/css.js +26 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/json.js +83 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/line.js +51 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/sentence.js +26 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/word.js +151 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.js +178 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/apply.js +168 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/create.js +301 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/line-endings.js +137 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/merge.js +367 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/parse.js +91 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/reverse.js +99 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/array.js +23 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/distance-iterator.js +30 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/params.js +22 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/string.js +97 -0
- package/dist/node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js +14 -0
- package/dist/node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js +16 -0
- package/dist/node_modules/.pnpm/he@1.2.0/node_modules/he/he.js +4093 -0
- package/dist/node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js +14 -0
- package/dist/node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js +27 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/index.js +12 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/context.js +83 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/error-constants.js +35 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/errors.js +392 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/hook.js +86 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/bdd.js +104 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/common.js +99 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/exports.js +65 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/index.js +18 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/qunit.js +95 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/tdd.js +105 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocha.js +1037 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocharc.js +24 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js +152 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/esm-utils.js +74 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/file-unloader.js +22 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js +329 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/serializer.js +314 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/pending.js +22 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/base.js +417 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/doc.js +79 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/dot.js +75 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/html.js +283 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/index.js +40 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json-stream.js +90 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json.js +145 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/landing.js +107 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/list.js +77 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/markdown.js +106 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/min.js +57 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/nyan.js +233 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/progress.js +92 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/spec.js +91 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/tap.js +261 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/xunit.js +166 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js +346 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runner.js +922 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js +72 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js +517 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js +105 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/utils.js +505 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/package.js +225 -0
- package/dist/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +124 -0
- package/dist/node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js +11 -0
- package/dist/node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js +114 -0
- package/dist/node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js +76 -0
- package/dist/node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js +89 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Pool.js +366 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Promise.js +248 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/WorkerHandler.js +419 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/debug-port-allocator.js +27 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/environment.js +18 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/generated/embeddedWorker.js +16 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/index.js +63 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/transfer.js +21 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/validateOptions.js +9 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js +277 -0
- package/dist/register.d.ts +10 -0
- package/dist/register.js +40 -0
- package/dist/typings/index.d.ts +1 -0
- package/package.json +71 -98
- package/dist/commonjs/app/extend/agent.d.ts +0 -34
- package/dist/commonjs/app/extend/agent.js +0 -49
- package/dist/commonjs/app/extend/application.d.ts +0 -172
- package/dist/commonjs/app/extend/application.js +0 -450
- package/dist/commonjs/app/middleware/cluster_app_mock.d.ts +0 -3
- package/dist/commonjs/app/middleware/cluster_app_mock.js +0 -101
- package/dist/commonjs/app.d.ts +0 -6
- package/dist/commonjs/app.js +0 -20
- package/dist/commonjs/bootstrap.d.ts +0 -5
- package/dist/commonjs/bootstrap.js +0 -59
- package/dist/commonjs/index.d.ts +0 -77
- package/dist/commonjs/index.js +0 -114
- package/dist/commonjs/lib/agent_handler.d.ts +0 -3
- package/dist/commonjs/lib/agent_handler.js +0 -28
- package/dist/commonjs/lib/app.d.ts +0 -3
- package/dist/commonjs/lib/app.js +0 -301
- package/dist/commonjs/lib/app_handler.d.ts +0 -5
- package/dist/commonjs/lib/app_handler.js +0 -71
- package/dist/commonjs/lib/cluster.d.ts +0 -114
- package/dist/commonjs/lib/cluster.js +0 -337
- package/dist/commonjs/lib/context.d.ts +0 -1
- package/dist/commonjs/lib/context.js +0 -16
- package/dist/commonjs/lib/format_options.d.ts +0 -5
- package/dist/commonjs/lib/format_options.js +0 -100
- package/dist/commonjs/lib/inject_context.d.ts +0 -6
- package/dist/commonjs/lib/inject_context.js +0 -132
- package/dist/commonjs/lib/mock_agent.d.ts +0 -5
- package/dist/commonjs/lib/mock_agent.js +0 -49
- package/dist/commonjs/lib/mock_custom_loader.d.ts +0 -1
- package/dist/commonjs/lib/mock_custom_loader.js +0 -37
- package/dist/commonjs/lib/mock_http_server.d.ts +0 -2
- package/dist/commonjs/lib/mock_http_server.js +0 -24
- package/dist/commonjs/lib/mock_httpclient.d.ts +0 -36
- package/dist/commonjs/lib/mock_httpclient.js +0 -147
- package/dist/commonjs/lib/parallel/agent.d.ts +0 -20
- package/dist/commonjs/lib/parallel/agent.js +0 -125
- package/dist/commonjs/lib/parallel/app.d.ts +0 -20
- package/dist/commonjs/lib/parallel/app.js +0 -115
- package/dist/commonjs/lib/parallel/util.d.ts +0 -3
- package/dist/commonjs/lib/parallel/util.js +0 -77
- package/dist/commonjs/lib/prerequire.d.ts +0 -1
- package/dist/commonjs/lib/prerequire.js +0 -26
- package/dist/commonjs/lib/request_call_function.d.ts +0 -1
- package/dist/commonjs/lib/request_call_function.js +0 -52
- package/dist/commonjs/lib/restore.d.ts +0 -1
- package/dist/commonjs/lib/restore.js +0 -16
- package/dist/commonjs/lib/start-cluster.d.ts +0 -2
- package/dist/commonjs/lib/start-cluster.js +0 -23
- package/dist/commonjs/lib/supertest.d.ts +0 -11
- package/dist/commonjs/lib/supertest.js +0 -48
- package/dist/commonjs/lib/tmp/empty.d.ts +0 -1
- package/dist/commonjs/lib/tmp/empty.js +0 -3
- package/dist/commonjs/lib/types.d.ts +0 -68
- package/dist/commonjs/lib/types.js +0 -3
- package/dist/commonjs/lib/utils.d.ts +0 -9
- package/dist/commonjs/lib/utils.js +0 -80
- package/dist/commonjs/package.json +0 -3
- package/dist/commonjs/register.d.ts +0 -8
- package/dist/commonjs/register.js +0 -80
- package/dist/esm/app/extend/agent.d.ts +0 -34
- package/dist/esm/app/extend/agent.js +0 -46
- package/dist/esm/app/extend/application.d.ts +0 -172
- package/dist/esm/app/extend/application.js +0 -444
- package/dist/esm/app/middleware/cluster_app_mock.d.ts +0 -3
- package/dist/esm/app/middleware/cluster_app_mock.js +0 -99
- package/dist/esm/app.d.ts +0 -6
- package/dist/esm/app.js +0 -17
- package/dist/esm/bootstrap.d.ts +0 -5
- package/dist/esm/bootstrap.js +0 -15
- package/dist/esm/index.d.ts +0 -77
- package/dist/esm/index.js +0 -91
- package/dist/esm/lib/agent_handler.d.ts +0 -3
- package/dist/esm/lib/agent_handler.js +0 -24
- package/dist/esm/lib/app.d.ts +0 -3
- package/dist/esm/lib/app.js +0 -295
- package/dist/esm/lib/app_handler.d.ts +0 -5
- package/dist/esm/lib/app_handler.js +0 -65
- package/dist/esm/lib/cluster.d.ts +0 -114
- package/dist/esm/lib/cluster.js +0 -328
- package/dist/esm/lib/context.d.ts +0 -1
- package/dist/esm/lib/context.js +0 -13
- package/dist/esm/lib/format_options.d.ts +0 -5
- package/dist/esm/lib/format_options.js +0 -94
- package/dist/esm/lib/inject_context.d.ts +0 -6
- package/dist/esm/lib/inject_context.js +0 -126
- package/dist/esm/lib/mock_agent.d.ts +0 -5
- package/dist/esm/lib/mock_agent.js +0 -45
- package/dist/esm/lib/mock_custom_loader.d.ts +0 -1
- package/dist/esm/lib/mock_custom_loader.js +0 -34
- package/dist/esm/lib/mock_http_server.d.ts +0 -2
- package/dist/esm/lib/mock_http_server.js +0 -18
- package/dist/esm/lib/mock_httpclient.d.ts +0 -36
- package/dist/esm/lib/mock_httpclient.js +0 -144
- package/dist/esm/lib/parallel/agent.d.ts +0 -20
- package/dist/esm/lib/parallel/agent.js +0 -117
- package/dist/esm/lib/parallel/app.d.ts +0 -20
- package/dist/esm/lib/parallel/app.js +0 -110
- package/dist/esm/lib/parallel/util.d.ts +0 -3
- package/dist/esm/lib/parallel/util.js +0 -73
- package/dist/esm/lib/prerequire.d.ts +0 -1
- package/dist/esm/lib/prerequire.js +0 -25
- package/dist/esm/lib/request_call_function.d.ts +0 -1
- package/dist/esm/lib/request_call_function.js +0 -47
- package/dist/esm/lib/restore.d.ts +0 -1
- package/dist/esm/lib/restore.js +0 -13
- package/dist/esm/lib/start-cluster.d.ts +0 -2
- package/dist/esm/lib/start-cluster.js +0 -18
- package/dist/esm/lib/supertest.d.ts +0 -11
- package/dist/esm/lib/supertest.js +0 -40
- package/dist/esm/lib/tmp/empty.d.ts +0 -1
- package/dist/esm/lib/tmp/empty.js +0 -2
- package/dist/esm/lib/types.d.ts +0 -68
- package/dist/esm/lib/types.js +0 -2
- package/dist/esm/lib/utils.d.ts +0 -9
- package/dist/esm/lib/utils.js +0 -69
- package/dist/esm/package.json +0 -3
- package/dist/esm/register.d.ts +0 -8
- package/dist/esm/register.js +0 -75
- package/dist/package.json +0 -4
- package/src/app/extend/agent.ts +0 -57
- package/src/app/extend/application.ts +0 -512
- package/src/app/middleware/cluster_app_mock.ts +0 -102
- package/src/app.ts +0 -18
- package/src/bootstrap.ts +0 -25
- package/src/index.ts +0 -112
- package/src/lib/agent_handler.ts +0 -28
- package/src/lib/app.ts +0 -314
- package/src/lib/app_handler.ts +0 -77
- package/src/lib/cluster.ts +0 -363
- package/src/lib/context.ts +0 -14
- package/src/lib/format_options.ts +0 -103
- package/src/lib/inject_context.ts +0 -134
- package/src/lib/mock_agent.ts +0 -57
- package/src/lib/mock_custom_loader.ts +0 -36
- package/src/lib/mock_http_server.ts +0 -19
- package/src/lib/mock_httpclient.ts +0 -183
- package/src/lib/parallel/agent.ts +0 -128
- package/src/lib/parallel/app.ts +0 -123
- package/src/lib/parallel/util.ts +0 -66
- package/src/lib/prerequire.ts +0 -25
- package/src/lib/request_call_function.ts +0 -49
- package/src/lib/restore.ts +0 -14
- package/src/lib/start-cluster.ts +0 -23
- package/src/lib/supertest.ts +0 -45
- package/src/lib/tmp/.gitkeep +0 -0
- package/src/lib/tmp/empty.ts +0 -0
- package/src/lib/utils.ts +0 -82
- package/src/register.ts +0 -80
- package/src/typings/index.d.ts +0 -4
|
@@ -0,0 +1,346 @@
|
|
|
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_pending } from "./pending.js";
|
|
5
|
+
import { require_src } from "../../../../debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js";
|
|
6
|
+
import { require_errors } from "./errors.js";
|
|
7
|
+
|
|
8
|
+
//#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js
|
|
9
|
+
var require_runnable = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js": ((exports, module) => {
|
|
10
|
+
var EventEmitter = __require("node:events").EventEmitter;
|
|
11
|
+
var Pending = require_pending();
|
|
12
|
+
var debug = require_src()("mocha:runnable");
|
|
13
|
+
var milliseconds = require_ms();
|
|
14
|
+
var utils = require_utils();
|
|
15
|
+
const { createInvalidExceptionError, createMultipleDoneError, createTimeoutError } = require_errors();
|
|
16
|
+
/**
|
|
17
|
+
* Save timer references to avoid Sinon interfering (see GH-237).
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
var Date = global.Date;
|
|
21
|
+
var setTimeout = global.setTimeout;
|
|
22
|
+
var clearTimeout = global.clearTimeout;
|
|
23
|
+
var toString = Object.prototype.toString;
|
|
24
|
+
var MAX_TIMEOUT = Math.pow(2, 31) - 1;
|
|
25
|
+
module.exports = Runnable;
|
|
26
|
+
/**
|
|
27
|
+
* Initialize a new `Runnable` with the given `title` and callback `fn`.
|
|
28
|
+
* Additional properties, like `getFullTitle()` and `slow()`, can be viewed in the `Runnable` source.
|
|
29
|
+
*
|
|
30
|
+
* @class
|
|
31
|
+
* @extends external:EventEmitter
|
|
32
|
+
* @public
|
|
33
|
+
* @param {String} title
|
|
34
|
+
* @param {Function} fn
|
|
35
|
+
*/
|
|
36
|
+
function Runnable(title, fn) {
|
|
37
|
+
this.title = title;
|
|
38
|
+
this.fn = fn;
|
|
39
|
+
this.body = (fn || "").toString();
|
|
40
|
+
this.async = fn && fn.length;
|
|
41
|
+
this.sync = !this.async;
|
|
42
|
+
this._timeout = 2e3;
|
|
43
|
+
this._slow = 75;
|
|
44
|
+
this._retries = -1;
|
|
45
|
+
utils.assignNewMochaID(this);
|
|
46
|
+
Object.defineProperty(this, "id", { get() {
|
|
47
|
+
return utils.getMochaID(this);
|
|
48
|
+
} });
|
|
49
|
+
this.reset();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Inherit from `EventEmitter.prototype`.
|
|
53
|
+
*/
|
|
54
|
+
utils.inherits(Runnable, EventEmitter);
|
|
55
|
+
/**
|
|
56
|
+
* Resets the state initially or for a next run.
|
|
57
|
+
*/
|
|
58
|
+
Runnable.prototype.reset = function() {
|
|
59
|
+
this.timedOut = false;
|
|
60
|
+
this._currentRetry = 0;
|
|
61
|
+
this.pending = false;
|
|
62
|
+
delete this.state;
|
|
63
|
+
delete this.err;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Get current timeout value in msecs.
|
|
67
|
+
*
|
|
68
|
+
* @private
|
|
69
|
+
* @returns {number} current timeout threshold value
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* @summary
|
|
73
|
+
* Set timeout threshold value (msecs).
|
|
74
|
+
*
|
|
75
|
+
* @description
|
|
76
|
+
* A string argument can use shorthand (e.g., "2s") and will be converted.
|
|
77
|
+
* The value will be clamped to range [<code>0</code>, <code>2^<sup>31</sup>-1</code>].
|
|
78
|
+
* If clamped value matches either range endpoint, timeouts will be disabled.
|
|
79
|
+
*
|
|
80
|
+
* @private
|
|
81
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Maximum_delay_value}
|
|
82
|
+
* @param {number|string} ms - Timeout threshold value.
|
|
83
|
+
* @returns {Runnable} this
|
|
84
|
+
* @chainable
|
|
85
|
+
*/
|
|
86
|
+
Runnable.prototype.timeout = function(ms) {
|
|
87
|
+
if (!arguments.length) return this._timeout;
|
|
88
|
+
if (typeof ms === "string") ms = milliseconds(ms);
|
|
89
|
+
var range = [0, MAX_TIMEOUT];
|
|
90
|
+
ms = utils.clamp(ms, range);
|
|
91
|
+
if (ms === range[0] || ms === range[1]) this._timeout = 0;
|
|
92
|
+
else this._timeout = ms;
|
|
93
|
+
debug("timeout %d", this._timeout);
|
|
94
|
+
if (this.timer) this.resetTimeout();
|
|
95
|
+
return this;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Set or get slow `ms`.
|
|
99
|
+
*
|
|
100
|
+
* @private
|
|
101
|
+
* @param {number|string} ms
|
|
102
|
+
* @return {Runnable|number} ms or Runnable instance.
|
|
103
|
+
*/
|
|
104
|
+
Runnable.prototype.slow = function(ms) {
|
|
105
|
+
if (!arguments.length || typeof ms === "undefined") return this._slow;
|
|
106
|
+
if (typeof ms === "string") ms = milliseconds(ms);
|
|
107
|
+
debug("slow %d", ms);
|
|
108
|
+
this._slow = ms;
|
|
109
|
+
return this;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Halt and mark as pending.
|
|
113
|
+
*
|
|
114
|
+
* @memberof Mocha.Runnable
|
|
115
|
+
* @public
|
|
116
|
+
*/
|
|
117
|
+
Runnable.prototype.skip = function() {
|
|
118
|
+
this.pending = true;
|
|
119
|
+
throw new Pending("sync skip; aborting execution");
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Check if this runnable or its parent suite is marked as pending.
|
|
123
|
+
*
|
|
124
|
+
* @private
|
|
125
|
+
*/
|
|
126
|
+
Runnable.prototype.isPending = function() {
|
|
127
|
+
return this.pending || this.parent && this.parent.isPending();
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Return `true` if this Runnable has failed.
|
|
131
|
+
* @return {boolean}
|
|
132
|
+
* @private
|
|
133
|
+
*/
|
|
134
|
+
Runnable.prototype.isFailed = function() {
|
|
135
|
+
return !this.isPending() && this.state === constants.STATE_FAILED;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Return `true` if this Runnable has passed.
|
|
139
|
+
* @return {boolean}
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
142
|
+
Runnable.prototype.isPassed = function() {
|
|
143
|
+
return !this.isPending() && this.state === constants.STATE_PASSED;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Set or get number of retries.
|
|
147
|
+
*
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
Runnable.prototype.retries = function(n) {
|
|
151
|
+
if (!arguments.length) return this._retries;
|
|
152
|
+
this._retries = n;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Set or get current retry
|
|
156
|
+
*
|
|
157
|
+
* @private
|
|
158
|
+
*/
|
|
159
|
+
Runnable.prototype.currentRetry = function(n) {
|
|
160
|
+
if (!arguments.length) return this._currentRetry;
|
|
161
|
+
this._currentRetry = n;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Return the full title generated by recursively concatenating the parent's
|
|
165
|
+
* full title.
|
|
166
|
+
*
|
|
167
|
+
* @memberof Mocha.Runnable
|
|
168
|
+
* @public
|
|
169
|
+
* @return {string}
|
|
170
|
+
*/
|
|
171
|
+
Runnable.prototype.fullTitle = function() {
|
|
172
|
+
return this.titlePath().join(" ");
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Return the title path generated by concatenating the parent's title path with the title.
|
|
176
|
+
*
|
|
177
|
+
* @memberof Mocha.Runnable
|
|
178
|
+
* @public
|
|
179
|
+
* @return {string[]}
|
|
180
|
+
*/
|
|
181
|
+
Runnable.prototype.titlePath = function() {
|
|
182
|
+
return this.parent.titlePath().concat([this.title]);
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Clear the timeout.
|
|
186
|
+
*
|
|
187
|
+
* @private
|
|
188
|
+
*/
|
|
189
|
+
Runnable.prototype.clearTimeout = function() {
|
|
190
|
+
clearTimeout(this.timer);
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Reset the timeout.
|
|
194
|
+
*
|
|
195
|
+
* @private
|
|
196
|
+
*/
|
|
197
|
+
Runnable.prototype.resetTimeout = function() {
|
|
198
|
+
var self = this;
|
|
199
|
+
var ms = this.timeout() || MAX_TIMEOUT;
|
|
200
|
+
this.clearTimeout();
|
|
201
|
+
this.timer = setTimeout(function() {
|
|
202
|
+
if (self.timeout() === 0) return;
|
|
203
|
+
self.callback(self._timeoutError(ms));
|
|
204
|
+
self.timedOut = true;
|
|
205
|
+
}, ms);
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Set or get a list of whitelisted globals for this test run.
|
|
209
|
+
*
|
|
210
|
+
* @private
|
|
211
|
+
* @param {string[]} globals
|
|
212
|
+
*/
|
|
213
|
+
Runnable.prototype.globals = function(globals) {
|
|
214
|
+
if (!arguments.length) return this._allowedGlobals;
|
|
215
|
+
this._allowedGlobals = globals;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Run the test and invoke `fn(err)`.
|
|
219
|
+
*
|
|
220
|
+
* @param {Function} fn
|
|
221
|
+
* @private
|
|
222
|
+
*/
|
|
223
|
+
Runnable.prototype.run = function(fn) {
|
|
224
|
+
var self = this;
|
|
225
|
+
var start = new Date();
|
|
226
|
+
var ctx = this.ctx;
|
|
227
|
+
var finished;
|
|
228
|
+
var errorWasHandled = false;
|
|
229
|
+
if (this.isPending()) return fn();
|
|
230
|
+
if (ctx && ctx.runnable) ctx.runnable(this);
|
|
231
|
+
function multiple(err) {
|
|
232
|
+
if (errorWasHandled) return;
|
|
233
|
+
errorWasHandled = true;
|
|
234
|
+
self.emit("error", createMultipleDoneError(self, err));
|
|
235
|
+
}
|
|
236
|
+
function done(err) {
|
|
237
|
+
var ms = self.timeout();
|
|
238
|
+
if (self.timedOut) return;
|
|
239
|
+
if (finished) return multiple(err);
|
|
240
|
+
self.clearTimeout();
|
|
241
|
+
self.duration = new Date() - start;
|
|
242
|
+
finished = true;
|
|
243
|
+
if (!err && self.duration > ms && ms > 0) err = self._timeoutError(ms);
|
|
244
|
+
fn(err);
|
|
245
|
+
}
|
|
246
|
+
this.callback = done;
|
|
247
|
+
if (this.fn && typeof this.fn.call !== "function") {
|
|
248
|
+
done(/* @__PURE__ */ new TypeError("A runnable must be passed a function as its second argument."));
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (this.async) {
|
|
252
|
+
this.resetTimeout();
|
|
253
|
+
this.skip = function asyncSkip() {
|
|
254
|
+
this.pending = true;
|
|
255
|
+
done();
|
|
256
|
+
throw new Pending("async skip; aborting execution");
|
|
257
|
+
};
|
|
258
|
+
try {
|
|
259
|
+
callFnAsync(this.fn);
|
|
260
|
+
} catch (err) {
|
|
261
|
+
errorWasHandled = true;
|
|
262
|
+
if (err instanceof Pending) return;
|
|
263
|
+
else if (this.allowUncaught) throw err;
|
|
264
|
+
done(Runnable.toValueOrError(err));
|
|
265
|
+
}
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
try {
|
|
269
|
+
callFn(this.fn);
|
|
270
|
+
} catch (err) {
|
|
271
|
+
errorWasHandled = true;
|
|
272
|
+
if (err instanceof Pending) return done();
|
|
273
|
+
else if (this.allowUncaught) throw err;
|
|
274
|
+
done(Runnable.toValueOrError(err));
|
|
275
|
+
}
|
|
276
|
+
function callFn(fn$1) {
|
|
277
|
+
var result = fn$1.call(ctx);
|
|
278
|
+
if (result && typeof result.then === "function") {
|
|
279
|
+
self.resetTimeout();
|
|
280
|
+
result.then(function() {
|
|
281
|
+
done();
|
|
282
|
+
return null;
|
|
283
|
+
}, function(reason) {
|
|
284
|
+
done(reason || /* @__PURE__ */ new Error("Promise rejected with no or falsy reason"));
|
|
285
|
+
});
|
|
286
|
+
} else {
|
|
287
|
+
if (self.asyncOnly) return done(/* @__PURE__ */ new Error("--async-only option in use without declaring `done()` or returning a promise"));
|
|
288
|
+
done();
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function callFnAsync(fn$1) {
|
|
292
|
+
var result = fn$1.call(ctx, function(err) {
|
|
293
|
+
if (err instanceof Error || toString.call(err) === "[object Error]") return done(err);
|
|
294
|
+
if (err) {
|
|
295
|
+
if (Object.prototype.toString.call(err) === "[object Object]") return done(/* @__PURE__ */ new Error("done() invoked with non-Error: " + JSON.stringify(err)));
|
|
296
|
+
return done(/* @__PURE__ */ new Error("done() invoked with non-Error: " + err));
|
|
297
|
+
}
|
|
298
|
+
if (result && utils.isPromise(result)) return done(/* @__PURE__ */ new Error("Resolution method is overspecified. Specify a callback *or* return a Promise; not both."));
|
|
299
|
+
done();
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* Instantiates a "timeout" error
|
|
305
|
+
*
|
|
306
|
+
* @param {number} ms - Timeout (in milliseconds)
|
|
307
|
+
* @returns {Error} a "timeout" error
|
|
308
|
+
* @private
|
|
309
|
+
*/
|
|
310
|
+
Runnable.prototype._timeoutError = function(ms) {
|
|
311
|
+
let msg = `Timeout of ${ms}ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.`;
|
|
312
|
+
if (this.file) msg += " (" + this.file + ")";
|
|
313
|
+
return createTimeoutError(msg, ms, this.file);
|
|
314
|
+
};
|
|
315
|
+
var constants = utils.defineConstants(
|
|
316
|
+
/**
|
|
317
|
+
* {@link Runnable}-related constants.
|
|
318
|
+
* @public
|
|
319
|
+
* @memberof Runnable
|
|
320
|
+
* @readonly
|
|
321
|
+
* @static
|
|
322
|
+
* @alias constants
|
|
323
|
+
* @enum {string}
|
|
324
|
+
*/
|
|
325
|
+
{
|
|
326
|
+
STATE_FAILED: "failed",
|
|
327
|
+
STATE_PASSED: "passed",
|
|
328
|
+
STATE_PENDING: "pending"
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
/**
|
|
332
|
+
* Given `value`, return identity if truthy, otherwise create an "invalid exception" error and return that.
|
|
333
|
+
* @param {*} [value] - Value to return, if present
|
|
334
|
+
* @returns {*|Error} `value`, otherwise an `Error`
|
|
335
|
+
* @private
|
|
336
|
+
*/
|
|
337
|
+
Runnable.toValueOrError = function(value) {
|
|
338
|
+
return value || createInvalidExceptionError("Runnable failed with falsy or undefined exception. Please throw an Error instead.", value);
|
|
339
|
+
};
|
|
340
|
+
Runnable.constants = constants;
|
|
341
|
+
}) });
|
|
342
|
+
|
|
343
|
+
//#endregion
|
|
344
|
+
export default require_runnable();
|
|
345
|
+
|
|
346
|
+
export { require_runnable };
|