@eggjs/mock 6.1.0-beta.7 → 6.1.0-beta.9
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/app/extend/agent.d.ts +2 -2
- package/dist/app/extend/agent.js +2 -2
- package/dist/app/extend/application.d.ts +7 -8
- package/dist/app/extend/application.js +2 -2
- package/dist/app/middleware/cluster_app_mock.d.ts +1 -1
- package/dist/app/middleware/cluster_app_mock.js +1 -1
- package/dist/app.d.ts +2 -2
- package/dist/app.js +1 -1
- package/dist/lib/context.js +0 -1
- package/dist/lib/mock_agent.d.ts +1 -1
- package/dist/lib/parallel/agent.d.ts +2 -2
- package/dist/lib/parallel/app.d.ts +2 -2
- package/dist/lib/parallel/app.js +3 -2
- package/dist/typings/index.d.ts +1 -1
- package/package.json +12 -9
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { MockHttpClientMethod, MockResultFunction, MockResultOptions } from "../../lib/mock_httpclient.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Agent } from "egg";
|
|
3
3
|
import { mock, restore } from "mm";
|
|
4
4
|
import * as urllib0 from "urllib";
|
|
5
5
|
|
|
6
6
|
//#region src/app/extend/agent.d.ts
|
|
7
|
-
declare abstract class AgentUnittest extends
|
|
7
|
+
declare abstract class AgentUnittest extends Agent {
|
|
8
8
|
[key: string]: any;
|
|
9
9
|
_mockHttpClient: MockHttpClientMethod;
|
|
10
10
|
/**
|
package/dist/app/extend/agent.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getMockAgent, restoreMockAgent } from "../../lib/mock_agent.js";
|
|
2
2
|
import { createMockHttpClient } from "../../lib/mock_httpclient.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Agent } from "egg";
|
|
4
4
|
import { mock, restore } from "mm";
|
|
5
5
|
|
|
6
6
|
//#region src/app/extend/agent.ts
|
|
7
|
-
var AgentUnittest = class extends
|
|
7
|
+
var AgentUnittest = class extends Agent {
|
|
8
8
|
_mockHttpClient;
|
|
9
9
|
/**
|
|
10
10
|
* mock httpclient
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { MockHttpClientMethod, MockResultFunction, MockResultOptions } from "../../lib/mock_httpclient.js";
|
|
2
2
|
import { EggTestRequest } from "../../lib/supertest.js";
|
|
3
3
|
import { MockOptions } from "../../lib/types.js";
|
|
4
|
-
import {
|
|
4
|
+
import { Application, Context } from "egg";
|
|
5
5
|
import { mock } from "mm";
|
|
6
6
|
import { IncomingMessage } from "node:http";
|
|
7
7
|
import { Logger } from "egg-logger";
|
|
8
|
-
import
|
|
9
|
-
import { HttpClient } from "urllib";
|
|
8
|
+
import { MockAgent } from "urllib";
|
|
10
9
|
|
|
11
10
|
//#region src/app/extend/application.d.ts
|
|
12
11
|
interface MockContextOptions {
|
|
@@ -23,14 +22,14 @@ interface MockContextData {
|
|
|
23
22
|
headers?: Record<string, string | string[]>;
|
|
24
23
|
[key: string]: any;
|
|
25
24
|
}
|
|
26
|
-
interface MockContext extends
|
|
25
|
+
interface MockContext extends Context {
|
|
27
26
|
service: any;
|
|
28
27
|
}
|
|
29
|
-
declare abstract class ApplicationUnittest extends
|
|
28
|
+
declare abstract class ApplicationUnittest extends Application {
|
|
30
29
|
[key: string]: any;
|
|
31
|
-
options: MockOptions &
|
|
30
|
+
options: MockOptions & Application['options'];
|
|
32
31
|
_mockHttpClient?: MockHttpClientMethod;
|
|
33
|
-
|
|
32
|
+
agent: NonNullable<Application['agent']>;
|
|
34
33
|
/**
|
|
35
34
|
* mock Context
|
|
36
35
|
* @function App#mockContext
|
|
@@ -117,7 +116,7 @@ declare abstract class ApplicationUnittest extends EggCore {
|
|
|
117
116
|
* get mock httpclient agent
|
|
118
117
|
* @function App#mockHttpclientAgent
|
|
119
118
|
*/
|
|
120
|
-
mockAgent():
|
|
119
|
+
mockAgent(): MockAgent;
|
|
121
120
|
mockAgentRestore(): Promise<void>;
|
|
122
121
|
/**
|
|
123
122
|
* @see mm#restore
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { request } from "../../lib/supertest.js";
|
|
2
2
|
import { getMockAgent, restoreMockAgent } from "../../lib/mock_agent.js";
|
|
3
3
|
import { createMockHttpClient } from "../../lib/mock_httpclient.js";
|
|
4
|
-
import {
|
|
4
|
+
import { Application } from "egg";
|
|
5
5
|
import assert from "node:assert";
|
|
6
6
|
import { mock, restore } from "mm";
|
|
7
7
|
import { debuglog } from "node:util";
|
|
@@ -16,7 +16,7 @@ const debug = debuglog("egg/mock/app/extend/application");
|
|
|
16
16
|
const ORIGIN_TYPES = Symbol("@eggjs/mock originTypes");
|
|
17
17
|
const BACKGROUND_TASKS = Symbol("Application#backgroundTasks");
|
|
18
18
|
const REUSED_CTX = Symbol("Context#reusedInSuite");
|
|
19
|
-
var ApplicationUnittest = class extends
|
|
19
|
+
var ApplicationUnittest = class extends Application {
|
|
20
20
|
_mockHttpClient;
|
|
21
21
|
/**
|
|
22
22
|
* mock Context
|
package/dist/app.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Application, ILifecycleBoot } from "egg";
|
|
2
2
|
|
|
3
3
|
//#region src/app.d.ts
|
|
4
4
|
declare class Boot implements ILifecycleBoot {
|
|
5
5
|
#private;
|
|
6
|
-
constructor(app:
|
|
6
|
+
constructor(app: Application);
|
|
7
7
|
configWillLoad(): void;
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
package/dist/app.js
CHANGED
package/dist/lib/context.js
CHANGED
|
@@ -2,7 +2,6 @@ import { utils } from "@eggjs/core";
|
|
|
2
2
|
|
|
3
3
|
//#region src/lib/context.ts
|
|
4
4
|
const context = { runInBackground(scope) {
|
|
5
|
-
/* istanbul ignore next */
|
|
6
5
|
const taskName = scope._name || scope.name || utils.getCalleeFromStack(true);
|
|
7
6
|
if (taskName) scope._name = taskName;
|
|
8
7
|
const promise = this._runInBackground(scope);
|
package/dist/lib/mock_agent.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { HttpClient, MockAgent } from "urllib";
|
|
|
3
3
|
//#region src/lib/mock_agent.d.ts
|
|
4
4
|
declare function getMockAgent(app?: {
|
|
5
5
|
httpClient?: HttpClient;
|
|
6
|
-
}): MockAgent
|
|
6
|
+
}): MockAgent;
|
|
7
7
|
declare function restoreMockAgent(): Promise<void>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { getMockAgent, restoreMockAgent };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MockApplicationOptions, MockOptions } from "../types.js";
|
|
2
2
|
import { APP_INIT } from "./util.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Agent } from "egg";
|
|
4
4
|
import { Base } from "sdk-base";
|
|
5
5
|
|
|
6
6
|
//#region src/lib/parallel/agent.d.ts
|
|
@@ -9,7 +9,7 @@ declare class MockAgent extends Base {
|
|
|
9
9
|
options: MockApplicationOptions;
|
|
10
10
|
baseDir: string;
|
|
11
11
|
[APP_INIT]: boolean;
|
|
12
|
-
_instance:
|
|
12
|
+
_instance: Agent;
|
|
13
13
|
constructor(options: MockApplicationOptions);
|
|
14
14
|
_init(): Promise<void>;
|
|
15
15
|
on(...args: any[]): this;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MockApplicationOptions, MockOptions } from "../types.js";
|
|
2
2
|
import { APP_INIT } from "./util.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Application } from "egg";
|
|
4
4
|
import { Base } from "sdk-base";
|
|
5
5
|
|
|
6
6
|
//#region src/lib/parallel/app.d.ts
|
|
@@ -9,7 +9,7 @@ declare class MockParallelApplication extends Base {
|
|
|
9
9
|
options: MockApplicationOptions;
|
|
10
10
|
baseDir: string;
|
|
11
11
|
[APP_INIT]: boolean;
|
|
12
|
-
_instance:
|
|
12
|
+
_instance: Application;
|
|
13
13
|
constructor(options: MockApplicationOptions);
|
|
14
14
|
_init(): Promise<void>;
|
|
15
15
|
on(...args: any[]): this;
|
package/dist/lib/parallel/app.js
CHANGED
|
@@ -4,6 +4,7 @@ import { formatOptions } from "../format_options.js";
|
|
|
4
4
|
import { context } from "../context.js";
|
|
5
5
|
import { setCustomLoader } from "../mock_custom_loader.js";
|
|
6
6
|
import { APP_INIT, proxyApp } from "./util.js";
|
|
7
|
+
import { Application } from "egg";
|
|
7
8
|
import { debuglog } from "node:util";
|
|
8
9
|
import { importModule } from "@eggjs/utils";
|
|
9
10
|
import { Base } from "sdk-base";
|
|
@@ -29,8 +30,8 @@ var MockParallelApplication = class extends Base {
|
|
|
29
30
|
if (!this.options.clusterPort) this.options.clusterPort = parseInt(process.env.CLUSTER_PORT);
|
|
30
31
|
if (!this.options.clusterPort) throw new Error("cannot get env.CLUSTER_PORT, parallel run fail");
|
|
31
32
|
debug("get clusterPort %s", this.options.clusterPort);
|
|
32
|
-
const { Application } = await importModule(this.options.framework);
|
|
33
|
-
const app = this._instance = new Application({ ...this.options });
|
|
33
|
+
const { Application: Application$1 } = await importModule(this.options.framework);
|
|
34
|
+
const app = this._instance = new Application$1({ ...this.options });
|
|
34
35
|
Object.assign(app.context, context);
|
|
35
36
|
setCustomLoader(app);
|
|
36
37
|
debug("app instantiate");
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import "egg";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/mock",
|
|
3
|
-
"version": "6.1.0-beta.
|
|
3
|
+
"version": "6.1.0-beta.9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"bugs": {
|
|
57
57
|
"url": "https://github.com/eggjs/egg/issues"
|
|
58
58
|
},
|
|
59
|
+
"homepage": "https://github.com/eggjs/egg/tree/next/packages/mock",
|
|
59
60
|
"keywords": [
|
|
60
61
|
"egg",
|
|
61
62
|
"mock"
|
|
@@ -76,10 +77,13 @@
|
|
|
76
77
|
"sdk-base": "^5.0.1",
|
|
77
78
|
"urllib": "^4.6.11",
|
|
78
79
|
"utility": "^2.5.0",
|
|
79
|
-
"@eggjs/core": "6.6.0-beta.
|
|
80
|
-
"@eggjs/extend2": "4.1.0-beta.
|
|
81
|
-
"@eggjs/supertest": "8.3.0-beta.
|
|
82
|
-
"@eggjs/utils": "4.5.0-beta.
|
|
80
|
+
"@eggjs/core": "6.6.0-beta.9",
|
|
81
|
+
"@eggjs/extend2": "4.1.0-beta.9",
|
|
82
|
+
"@eggjs/supertest": "8.3.0-beta.9",
|
|
83
|
+
"@eggjs/utils": "4.5.0-beta.9"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"egg": "4.1.0-beta.9"
|
|
83
87
|
},
|
|
84
88
|
"devDependencies": {
|
|
85
89
|
"@eggjs/tegg": "^3.2.2",
|
|
@@ -87,15 +91,14 @@
|
|
|
87
91
|
"@eggjs/tegg-controller-plugin": "^3.2.2",
|
|
88
92
|
"@eggjs/tegg-plugin": "^3.2.2",
|
|
89
93
|
"@types/methods": "^1.1.4",
|
|
90
|
-
"@types/node": "24",
|
|
94
|
+
"@types/node": "24.5.2",
|
|
91
95
|
"egg-errors": "^2.3.2",
|
|
92
96
|
"egg-tracer": "^2.1.0",
|
|
93
97
|
"pedding": "^2.0.1",
|
|
94
98
|
"tsd": "^0.33.0",
|
|
95
|
-
"tsdown": "
|
|
99
|
+
"tsdown": "0.15.3",
|
|
96
100
|
"typescript": "5.9.2",
|
|
97
|
-
"
|
|
98
|
-
"egg": "4.1.0-beta.7"
|
|
101
|
+
"egg": "4.1.0-beta.9"
|
|
99
102
|
},
|
|
100
103
|
"scripts": {
|
|
101
104
|
"build": "tsdown",
|