@eggjs/mock 7.0.0-beta.34 → 7.0.0-beta.36
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/dist/_virtual/rolldown_runtime.js +7 -0
- package/dist/app/extend/agent.d.ts +38 -34
- package/dist/app/extend/agent.js +48 -46
- package/dist/app/extend/application.d.ts +171 -167
- package/dist/app/extend/application.js +382 -442
- package/dist/app/middleware/cluster_app_mock.d.ts +5 -2
- package/dist/app/middleware/cluster_app_mock.js +95 -100
- package/dist/app.d.ts +9 -5
- package/dist/app.js +17 -18
- package/dist/bootstrap.d.ts +9 -5
- package/dist/bootstrap.js +11 -12
- package/dist/index.d.ts +20 -17
- package/dist/index.js +39 -78
- package/dist/inject_mocha.d.ts +1 -1
- package/dist/inject_mocha.js +27 -28
- package/dist/lib/agent_handler.d.ts +7 -3
- package/dist/lib/agent_handler.js +22 -20
- package/dist/lib/app.d.ts +7 -3
- package/dist/lib/app.js +246 -287
- package/dist/lib/app_handler.d.ts +9 -5
- package/dist/lib/app_handler.js +48 -61
- package/dist/lib/cluster.d.ts +122 -118
- package/dist/lib/cluster.js +278 -335
- package/dist/lib/context.d.ts +4 -1
- package/dist/lib/context.js +10 -11
- package/dist/lib/format_options.d.ts +9 -4
- package/dist/lib/format_options.js +60 -88
- package/dist/lib/inject_context.d.ts +8 -5
- package/dist/lib/inject_context.js +103 -123
- package/dist/lib/mock_agent.d.ts +8 -4
- package/dist/lib/mock_agent.js +42 -42
- package/dist/lib/mock_custom_loader.d.ts +4 -1
- package/dist/lib/mock_custom_loader.js +34 -33
- package/dist/lib/mock_http_server.d.ts +6 -2
- package/dist/lib/mock_http_server.js +16 -17
- package/dist/lib/mock_httpclient.d.ts +38 -34
- package/dist/lib/mock_httpclient.js +106 -142
- package/dist/lib/parallel/agent.d.ts +22 -18
- package/dist/lib/parallel/agent.js +106 -112
- package/dist/lib/parallel/app.d.ts +23 -19
- package/dist/lib/parallel/app.js +93 -106
- package/dist/lib/parallel/util.d.ts +5 -2
- package/dist/lib/parallel/util.js +56 -63
- package/dist/lib/prerequire.d.ts +1 -1
- package/dist/lib/prerequire.js +1 -25
- package/dist/lib/request_call_function.d.ts +1 -1
- package/dist/lib/request_call_function.js +34 -47
- package/dist/lib/restore.d.ts +4 -1
- package/dist/lib/restore.js +14 -11
- package/dist/lib/start-cluster.d.ts +1 -2
- package/dist/lib/start-cluster.js +15 -14
- package/dist/lib/supertest.d.ts +14 -9
- package/dist/lib/supertest.js +32 -36
- package/dist/lib/tmp/empty.d.ts +1 -1
- package/dist/lib/tmp/empty.js +1 -2
- package/dist/lib/types.d.ts +71 -67
- package/dist/lib/types.js +1 -2
- package/dist/lib/utils.d.ts +11 -8
- package/dist/lib/utils.js +34 -63
- package/dist/register.d.ts +11 -7
- package/dist/register.js +36 -40
- package/dist/typings/index.d.ts +1 -0
- package/package.json +36 -39
package/dist/register.js
CHANGED
|
@@ -1,44 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mock } from "./index.js";
|
|
3
|
-
import { setupAgent, closeAgent } from "./lib/agent_handler.js";
|
|
1
|
+
import { closeAgent, setupAgent } from "./lib/agent_handler.js";
|
|
4
2
|
import { getApp } from "./lib/app_handler.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import { mm as proxyMock } from "./index.js";
|
|
4
|
+
import "./inject_mocha.js";
|
|
5
|
+
import { debuglog } from "node:util";
|
|
6
|
+
|
|
7
|
+
//#region src/register.ts
|
|
8
|
+
const debug = debuglog("egg/mock/register");
|
|
9
|
+
async function mochaGlobalSetup() {
|
|
10
|
+
debug("mochaGlobalSetup, agent.setupAgent() start");
|
|
11
|
+
await setupAgent();
|
|
12
|
+
debug("mochaGlobalSetup, agent.setupAgent() end");
|
|
10
13
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
async function mochaGlobalTeardown() {
|
|
15
|
+
debug("mochaGlobalTeardown, agent.closeAgent() start");
|
|
16
|
+
await closeAgent();
|
|
17
|
+
debug("mochaGlobalTeardown, agent.closeAgent() end");
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (process.env.ENABLE_MOCHA_PARALLEL)
|
|
35
|
-
return;
|
|
36
|
-
const app = await getApp();
|
|
37
|
-
debug('mochaHooks.afterAll call, _app: %s', app);
|
|
38
|
-
if (app) {
|
|
39
|
-
await app.close();
|
|
40
|
-
}
|
|
41
|
-
},
|
|
19
|
+
const mochaHooks = {
|
|
20
|
+
async beforeAll() {
|
|
21
|
+
const app = await getApp();
|
|
22
|
+
debug("mochaHooks.beforeAll call, _app: %s", app);
|
|
23
|
+
if (app) await app.ready();
|
|
24
|
+
},
|
|
25
|
+
async afterEach() {
|
|
26
|
+
const app = await getApp();
|
|
27
|
+
debug("mochaHooks.afterEach call, _app: %s", app);
|
|
28
|
+
if (app) await app.backgroundTasksFinished();
|
|
29
|
+
await proxyMock.restore();
|
|
30
|
+
},
|
|
31
|
+
async afterAll() {
|
|
32
|
+
if (process.env.ENABLE_MOCHA_PARALLEL) return;
|
|
33
|
+
const app = await getApp();
|
|
34
|
+
debug("mochaHooks.afterAll call, _app: %s", app);
|
|
35
|
+
if (app) await app.close();
|
|
36
|
+
}
|
|
42
37
|
};
|
|
43
|
-
|
|
44
|
-
//#
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { mochaGlobalSetup, mochaGlobalTeardown, mochaHooks };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "egg";
|
package/package.json
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/mock",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"version": "7.0.0-beta.36",
|
|
4
|
+
"description": "mock server plugin for egg",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"egg",
|
|
7
|
+
"mock"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/eggjs/egg/tree/next/packages/mock",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/eggjs/egg/issues"
|
|
6
12
|
},
|
|
7
|
-
"
|
|
8
|
-
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "popomore <sakura9515@gmail.com>",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/eggjs/egg.git",
|
|
18
|
+
"directory": "plugins/mock"
|
|
9
19
|
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
10
23
|
"type": "module",
|
|
11
24
|
"main": "./dist/index.js",
|
|
12
25
|
"module": "./dist/index.js",
|
|
@@ -44,26 +57,8 @@
|
|
|
44
57
|
"./register": "./dist/register.js",
|
|
45
58
|
"./package.json": "./package.json"
|
|
46
59
|
},
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
],
|
|
50
|
-
"description": "mock server plugin for egg",
|
|
51
|
-
"repository": {
|
|
52
|
-
"type": "git",
|
|
53
|
-
"url": "git://github.com/eggjs/egg.git",
|
|
54
|
-
"directory": "packages/mock"
|
|
55
|
-
},
|
|
56
|
-
"bugs": {
|
|
57
|
-
"url": "https://github.com/eggjs/egg/issues"
|
|
58
|
-
},
|
|
59
|
-
"homepage": "https://github.com/eggjs/egg/tree/next/packages/mock",
|
|
60
|
-
"keywords": [
|
|
61
|
-
"egg",
|
|
62
|
-
"mock"
|
|
63
|
-
],
|
|
64
|
-
"author": "popomore <sakura9515@gmail.com>",
|
|
65
|
-
"engines": {
|
|
66
|
-
"node": ">=22.18.0"
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
67
62
|
},
|
|
68
63
|
"dependencies": {
|
|
69
64
|
"coffee": "5",
|
|
@@ -76,25 +71,27 @@
|
|
|
76
71
|
"sdk-base": "^5.0.1",
|
|
77
72
|
"urllib": "^4.8.2",
|
|
78
73
|
"utility": "^2.5.0",
|
|
79
|
-
"@eggjs/
|
|
80
|
-
"@eggjs/
|
|
81
|
-
"@eggjs/utils": "5.0.0-beta.
|
|
82
|
-
},
|
|
83
|
-
"peerDependencies": {
|
|
84
|
-
"egg": "4.1.0-beta.34"
|
|
74
|
+
"@eggjs/extend2": "5.0.0-beta.36",
|
|
75
|
+
"@eggjs/supertest": "9.0.0-beta.36",
|
|
76
|
+
"@eggjs/utils": "5.0.0-beta.36"
|
|
85
77
|
},
|
|
86
78
|
"devDependencies": {
|
|
87
79
|
"@types/methods": "^1.1.4",
|
|
88
|
-
"tsdown": "0.15.11",
|
|
89
80
|
"typescript": "^5.9.3",
|
|
90
|
-
"@eggjs/errors": "3.0.0-beta.
|
|
91
|
-
"@eggjs/tracer": "4.0.0-beta.
|
|
92
|
-
"egg": "4.1.0-beta.
|
|
81
|
+
"@eggjs/errors": "3.0.0-beta.36",
|
|
82
|
+
"@eggjs/tracer": "4.0.0-beta.36",
|
|
83
|
+
"egg": "4.1.0-beta.36"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"egg": "4.1.0-beta.36"
|
|
87
|
+
},
|
|
88
|
+
"engines": {
|
|
89
|
+
"node": ">=22.18.0"
|
|
90
|
+
},
|
|
91
|
+
"eggPlugin": {
|
|
92
|
+
"name": "egg-mock"
|
|
93
93
|
},
|
|
94
94
|
"scripts": {
|
|
95
|
-
"
|
|
96
|
-
"lint": "oxlint",
|
|
97
|
-
"typecheck": "tsc --noEmit",
|
|
98
|
-
"test": "vitest run"
|
|
95
|
+
"typecheck": "tsgo --noEmit"
|
|
99
96
|
}
|
|
100
97
|
}
|