@eggjs/mock 7.0.0-beta.19 → 7.0.0-beta.21

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 (63) hide show
  1. package/dist/app/extend/agent.d.ts +33 -38
  2. package/dist/app/extend/agent.js +45 -47
  3. package/dist/app/extend/application.d.ts +167 -171
  4. package/dist/app/extend/application.js +442 -382
  5. package/dist/app/middleware/cluster_app_mock.d.ts +2 -5
  6. package/dist/app/middleware/cluster_app_mock.js +99 -96
  7. package/dist/app.d.ts +5 -9
  8. package/dist/app.js +18 -17
  9. package/dist/bootstrap.d.ts +5 -9
  10. package/dist/bootstrap.js +12 -11
  11. package/dist/index.d.ts +76 -80
  12. package/dist/index.js +81 -38
  13. package/dist/inject_mocha.d.ts +1 -1
  14. package/dist/inject_mocha.js +28 -27
  15. package/dist/lib/agent_handler.d.ts +3 -7
  16. package/dist/lib/agent_handler.js +20 -22
  17. package/dist/lib/app.d.ts +3 -7
  18. package/dist/lib/app.js +285 -248
  19. package/dist/lib/app_handler.d.ts +5 -9
  20. package/dist/lib/app_handler.js +62 -49
  21. package/dist/lib/cluster.d.ts +92 -97
  22. package/dist/lib/cluster.js +335 -278
  23. package/dist/lib/context.d.ts +1 -4
  24. package/dist/lib/context.js +11 -10
  25. package/dist/lib/format_options.d.ts +2 -7
  26. package/dist/lib/format_options.js +88 -60
  27. package/dist/lib/inject_context.d.ts +1 -4
  28. package/dist/lib/inject_context.js +123 -103
  29. package/dist/lib/mock_agent.d.ts +4 -8
  30. package/dist/lib/mock_agent.js +42 -42
  31. package/dist/lib/mock_custom_loader.d.ts +1 -4
  32. package/dist/lib/mock_custom_loader.js +33 -34
  33. package/dist/lib/mock_http_server.d.ts +2 -6
  34. package/dist/lib/mock_http_server.js +17 -16
  35. package/dist/lib/mock_httpclient.d.ts +34 -38
  36. package/dist/lib/mock_httpclient.js +142 -106
  37. package/dist/lib/parallel/agent.d.ts +19 -23
  38. package/dist/lib/parallel/agent.js +113 -107
  39. package/dist/lib/parallel/app.d.ts +19 -23
  40. package/dist/lib/parallel/app.js +108 -96
  41. package/dist/lib/parallel/util.d.ts +3 -6
  42. package/dist/lib/parallel/util.js +64 -57
  43. package/dist/lib/prerequire.d.ts +1 -1
  44. package/dist/lib/prerequire.js +25 -1
  45. package/dist/lib/request_call_function.d.ts +1 -1
  46. package/dist/lib/request_call_function.js +47 -34
  47. package/dist/lib/restore.d.ts +1 -4
  48. package/dist/lib/restore.js +11 -14
  49. package/dist/lib/start-cluster.d.ts +2 -1
  50. package/dist/lib/start-cluster.js +14 -15
  51. package/dist/lib/supertest.d.ts +6 -11
  52. package/dist/lib/supertest.js +36 -35
  53. package/dist/lib/tmp/empty.d.ts +1 -1
  54. package/dist/lib/tmp/empty.js +2 -1
  55. package/dist/lib/types.d.ts +64 -68
  56. package/dist/lib/types.js +2 -1
  57. package/dist/lib/utils.d.ts +8 -11
  58. package/dist/lib/utils.js +63 -34
  59. package/dist/register.d.ts +7 -9
  60. package/dist/register.js +40 -36
  61. package/package.json +7 -8
  62. package/dist/_virtual/rolldown_runtime.js +0 -7
  63. package/dist/typings/index.d.ts +0 -1
@@ -1,39 +1,34 @@
1
- import { MockHttpClientMethod, MockResultFunction, MockResultOptions } from "../../lib/mock_httpclient.js";
2
- import { Agent } from "egg";
3
- import { mock, restore } from "mm";
4
- import * as urllib0 from "urllib";
5
-
6
- //#region src/app/extend/agent.d.ts
7
- declare abstract class AgentUnittest extends Agent {
8
- [key: string]: any;
9
- _mockHttpClient: MockHttpClientMethod;
10
- /**
11
- * mock httpclient
12
- * @alias mockHttpClient
13
- * @function App#mockHttpclient
14
- */
15
- mockHttpclient(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): void;
16
- /**
17
- * mock httpclient
18
- * @function App#mockHttpClient
19
- */
20
- mockHttpClient(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): void;
21
- /**
22
- * get mock httpclient agent
23
- * @function Agent#mockHttpclientAgent
24
- */
25
- mockAgent(): urllib0.MockAgent<urllib0.MockAgent.Options>;
26
- mockAgentRestore(): Promise<void>;
27
- /**
28
- * @see mm#restore
29
- * @function Agent#mockRestore
30
- */
31
- mockRestore: typeof restore;
32
- /**
33
- * @see mm
34
- * @function Agent#mm
35
- */
36
- mm: typeof mock;
1
+ import { mock, restore } from 'mm';
2
+ import { Agent } from 'egg';
3
+ import { type MockResultFunction, type MockResultOptions, type MockHttpClientMethod } from '../../lib/mock_httpclient.ts';
4
+ export default abstract class AgentUnittest extends Agent {
5
+ [key: string]: any;
6
+ _mockHttpClient: MockHttpClientMethod;
7
+ /**
8
+ * mock httpclient
9
+ * @alias mockHttpClient
10
+ * @function App#mockHttpclient
11
+ */
12
+ mockHttpclient(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): void;
13
+ /**
14
+ * mock httpclient
15
+ * @function App#mockHttpClient
16
+ */
17
+ mockHttpClient(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): void;
18
+ /**
19
+ * get mock httpclient agent
20
+ * @function Agent#mockHttpclientAgent
21
+ */
22
+ mockAgent(): import("urllib").MockAgent<import("urllib").MockAgent.Options>;
23
+ mockAgentRestore(): Promise<void>;
24
+ /**
25
+ * @see mm#restore
26
+ * @function Agent#mockRestore
27
+ */
28
+ mockRestore: typeof restore;
29
+ /**
30
+ * @see mm
31
+ * @function Agent#mm
32
+ */
33
+ mm: typeof mock;
37
34
  }
38
- //#endregion
39
- export { AgentUnittest as default };
@@ -1,48 +1,46 @@
1
+ import { mock, restore } from 'mm';
2
+ import { Agent } from 'egg';
3
+ import { createMockHttpClient, } from "../../lib/mock_httpclient.js";
1
4
  import { getMockAgent, restoreMockAgent } from "../../lib/mock_agent.js";
2
- import { createMockHttpClient } from "../../lib/mock_httpclient.js";
3
- import { Agent } from "egg";
4
- import { mock, restore } from "mm";
5
-
6
- //#region src/app/extend/agent.ts
7
- var AgentUnittest = class extends Agent {
8
- _mockHttpClient;
9
- /**
10
- * mock httpclient
11
- * @alias mockHttpClient
12
- * @function App#mockHttpclient
13
- */
14
- mockHttpclient(mockUrl, mockMethod, mockResult) {
15
- return this.mockHttpClient(mockUrl, mockMethod, mockResult);
16
- }
17
- /**
18
- * mock httpclient
19
- * @function App#mockHttpClient
20
- */
21
- mockHttpClient(mockUrl, mockMethod, mockResult) {
22
- if (!this._mockHttpClient) this._mockHttpClient = createMockHttpClient(this);
23
- return this._mockHttpClient(mockUrl, mockMethod, mockResult);
24
- }
25
- /**
26
- * get mock httpclient agent
27
- * @function Agent#mockHttpclientAgent
28
- */
29
- mockAgent() {
30
- return getMockAgent(this);
31
- }
32
- async mockAgentRestore() {
33
- await restoreMockAgent();
34
- }
35
- /**
36
- * @see mm#restore
37
- * @function Agent#mockRestore
38
- */
39
- mockRestore = restore;
40
- /**
41
- * @see mm
42
- * @function Agent#mm
43
- */
44
- mm = mock;
45
- };
46
-
47
- //#endregion
48
- export { AgentUnittest as default };
5
+ export default class AgentUnittest extends Agent {
6
+ _mockHttpClient;
7
+ /**
8
+ * mock httpclient
9
+ * @alias mockHttpClient
10
+ * @function App#mockHttpclient
11
+ */
12
+ mockHttpclient(mockUrl, mockMethod, mockResult) {
13
+ return this.mockHttpClient(mockUrl, mockMethod, mockResult);
14
+ }
15
+ /**
16
+ * mock httpclient
17
+ * @function App#mockHttpClient
18
+ */
19
+ mockHttpClient(mockUrl, mockMethod, mockResult) {
20
+ if (!this._mockHttpClient) {
21
+ this._mockHttpClient = createMockHttpClient(this);
22
+ }
23
+ return this._mockHttpClient(mockUrl, mockMethod, mockResult);
24
+ }
25
+ /**
26
+ * get mock httpclient agent
27
+ * @function Agent#mockHttpclientAgent
28
+ */
29
+ mockAgent() {
30
+ return getMockAgent(this);
31
+ }
32
+ async mockAgentRestore() {
33
+ await restoreMockAgent();
34
+ }
35
+ /**
36
+ * @see mm#restore
37
+ * @function Agent#mockRestore
38
+ */
39
+ mockRestore = restore;
40
+ /**
41
+ * @see mm
42
+ * @function Agent#mm
43
+ */
44
+ mm = mock;
45
+ }
46
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWdlbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXBwL2V4dGVuZC9hZ2VudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsSUFBSSxFQUFFLE9BQU8sRUFBRSxNQUFNLElBQUksQ0FBQztBQUNuQyxPQUFPLEVBQUUsS0FBSyxFQUFFLE1BQU0sS0FBSyxDQUFDO0FBRTVCLE9BQU8sRUFDTCxvQkFBb0IsR0FJckIsTUFBTSw4QkFBOEIsQ0FBQztBQUN0QyxPQUFPLEVBQUUsWUFBWSxFQUFFLGdCQUFnQixFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFekUsTUFBTSxDQUFDLE9BQU8sT0FBZ0IsYUFBYyxTQUFRLEtBQUs7SUFFdkQsZUFBZSxDQUF1QjtJQUV0Qzs7OztPQUlHO0lBQ0gsY0FBYyxDQUNaLE9BQXdCLEVBQ3hCLFVBQXNFLEVBQ3RFLFVBQTREO1FBRTVELE9BQU8sSUFBSSxDQUFDLGNBQWMsQ0FBQyxPQUFPLEVBQUUsVUFBVSxFQUFFLFVBQVUsQ0FBQyxDQUFDO0lBQzlELENBQUM7SUFFRDs7O09BR0c7SUFDSCxjQUFjLENBQ1osT0FBd0IsRUFDeEIsVUFBc0UsRUFDdEUsVUFBNEQ7UUFFNUQsSUFBSSxDQUFDLElBQUksQ0FBQyxlQUFlLEVBQUUsQ0FBQztZQUMxQixJQUFJLENBQUMsZUFBZSxHQUFHLG9CQUFvQixDQUFDLElBQUksQ0FBQyxDQUFDO1FBQ3BELENBQUM7UUFDRCxPQUFPLElBQUksQ0FBQyxlQUFlLENBQUMsT0FBTyxFQUFFLFVBQVUsRUFBRSxVQUFVLENBQUMsQ0FBQztJQUMvRCxDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsU0FBUztRQUNQLE9BQU8sWUFBWSxDQUFDLElBQVcsQ0FBQyxDQUFDO0lBQ25DLENBQUM7SUFFRCxLQUFLLENBQUMsZ0JBQWdCO1FBQ3BCLE1BQU0sZ0JBQWdCLEVBQUUsQ0FBQztJQUMzQixDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsV0FBVyxHQUFHLE9BQU8sQ0FBQztJQUV0Qjs7O09BR0c7SUFDSCxFQUFFLEdBQUcsSUFBSSxDQUFDO0NBQ1gifQ==
@@ -1,175 +1,171 @@
1
- import { MockHttpClientMethod, MockResultFunction, MockResultOptions } from "../../lib/mock_httpclient.js";
2
- import { EggTestRequest } from "../../lib/supertest.js";
3
- import { MockOptions } from "../../lib/types.js";
4
- import { Application, Context } from "egg";
5
- import { mock } from "mm";
6
- import { IncomingMessage } from "node:http";
7
- import { Logger } from "egg-logger";
8
- import { MockAgent } from "urllib";
9
-
10
- //#region src/app/extend/application.d.ts
11
- interface MockContextOptions {
12
- /**
13
- * mock ctxStorage or not, default is `true`
14
- */
15
- mockCtxStorage?: boolean;
16
- /**
17
- * reuse ctxStorage or not, default is `true`
18
- */
19
- reuseCtxStorage?: boolean;
1
+ import { IncomingMessage } from 'node:http';
2
+ import { mock } from 'mm';
3
+ import { Logger } from 'egg-logger';
4
+ import { type Context, Application } from 'egg';
5
+ import type { MockAgent } from 'urllib';
6
+ import { type MockResultFunction, type MockResultOptions, type MockHttpClientMethod } from '../../lib/mock_httpclient.ts';
7
+ import { EggTestRequest } from '../../lib/supertest.ts';
8
+ import { type MockOptions } from '../../lib/types.ts';
9
+ export interface MockContextOptions {
10
+ /**
11
+ * mock ctxStorage or not, default is `true`
12
+ */
13
+ mockCtxStorage?: boolean;
14
+ /**
15
+ * reuse ctxStorage or not, default is `true`
16
+ */
17
+ reuseCtxStorage?: boolean;
20
18
  }
21
- interface MockContextData {
22
- headers?: Record<string, string | string[]>;
23
- [key: string]: any;
19
+ export interface MockContextData {
20
+ headers?: Record<string, string | string[]>;
21
+ [key: string]: any;
24
22
  }
25
- interface MockContext extends Context {
26
- service: any;
23
+ export interface MockContext extends Context {
24
+ service: any;
27
25
  }
28
- declare abstract class ApplicationUnittest extends Application {
29
- [key: string]: any;
30
- options: MockOptions & Application['options'];
31
- _mockHttpClient?: MockHttpClientMethod;
32
- agent: NonNullable<Application['agent']>;
33
- /**
34
- * mock Context
35
- * @function App#mockContext
36
- * @param {Object} data - ctx data
37
- * @param {Object} [options] - mock ctx options
38
- * @example
39
- * ```js
40
- * const ctx = app.mockContext({
41
- * user: {
42
- * name: 'Jason'
43
- * }
44
- * });
45
- * console.log(ctx.user.name); // Jason
46
- *
47
- * // controller
48
- * module.exports = function*() {
49
- * this.body = this.user.name;
50
- * };
51
- * ```
52
- */
53
- mockContext(data?: MockContextData, options?: MockContextOptions): MockContext;
54
- mockContextScope(fn: (ctx?: MockContext) => Promise<any>, data?: MockContextData): Promise<any>;
55
- /**
56
- * mock cookie session
57
- * @function App#mockSession
58
- * @param {Object} data - session object
59
- */
60
- mockSession(data: any): this;
61
- /**
62
- * Mock service
63
- * @function App#mockService
64
- * @param {String} service - name
65
- * @param {String} methodName - method
66
- * @param {Object|Function|Error} fn - mock you data
67
- */
68
- mockService(service: string | any, methodName: string, fn: any): this;
69
- /**
70
- * mock service that return error
71
- * @function App#mockServiceError
72
- * @param {String} service - name
73
- * @param {String} methodName - method
74
- * @param {Error} [err] - error information
75
- */
76
- mockServiceError(service: string | any, methodName: string, err?: string | Error): this;
77
- _mockFn(obj: any, name: string, data: any): void;
78
- /**
79
- * mock request
80
- * @function App#mockRequest
81
- * @param {Request} req - mock request
82
- */
83
- mockRequest(req: MockContextData): IncomingMessage;
84
- /**
85
- * mock cookies
86
- * @function App#mockCookies
87
- */
88
- mockCookies(cookies: Record<string, string | string[]>): this;
89
- /**
90
- * mock header
91
- * @function App#mockHeaders
92
- */
93
- mockHeaders(headers: Record<string, string | string[]>): this;
94
- /**
95
- * mock csrf
96
- * @function App#mockCsrf
97
- * @since 1.11
98
- */
99
- mockCsrf(): this;
100
- /**
101
- * mock httpclient
102
- * @alias mockHttpClient
103
- * @function App#mockHttpclient
104
- */
105
- mockHttpclient(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): this;
106
- /**
107
- * mock httpclient
108
- * @function App#mockHttpClient
109
- */
110
- mockHttpClient(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): this;
111
- /**
112
- * @deprecated Please use app.mockHttpClient instead of app.mockUrllib
113
- */
114
- mockUrllib(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): this;
115
- /**
116
- * get mock httpclient agent
117
- * @function App#mockHttpclientAgent
118
- */
119
- mockAgent(): MockAgent;
120
- mockAgentRestore(): Promise<void>;
121
- /**
122
- * @see mm#restore
123
- * @function App#mockRestore
124
- */
125
- mockRestore(): Promise<void>;
126
- /**
127
- * @see mm
128
- * @function App#mm
129
- */
130
- get mm(): typeof mock;
131
- /**
132
- * override loadAgent
133
- * @function App#loadAgent
134
- */
135
- loadAgent(): void;
136
- /**
137
- * mock serverEnv
138
- * @function App#mockEnv
139
- * @param {String} env - serverEnv
140
- */
141
- mockEnv(env: string): this;
142
- /**
143
- * http request helper
144
- * @function App#httpRequest
145
- * @return {SupertestRequest} req - supertest request
146
- * @see https://github.com/visionmedia/supertest
147
- */
148
- httpRequest(): EggTestRequest;
149
- /**
150
- * collection logger message, then can be use on `expectLog()`
151
- * @param {String|Logger} [logger] - logger instance, default is `app.logger`
152
- * @function App#mockLog
153
- */
154
- mockLog(logger?: string | Logger): void;
155
- __checkExpectLog(expectOrNot: boolean, str: string | RegExp, logger?: string | Logger): void;
156
- /**
157
- * expect str/regexp in the logger, if your server disk is slow, please call `mockLog()` first.
158
- * @param {String|RegExp} str - test str or regexp
159
- * @param {String|Logger} [logger] - logger instance, default is `ctx.logger`
160
- * @function App#expectLog
161
- */
162
- expectLog(str: string | RegExp, logger?: string | Logger): void;
163
- /**
164
- * not expect str/regexp in the logger, if your server disk is slow, please call `mockLog()` first.
165
- * @param {String|RegExp} str - test str or regexp
166
- * @param {String|Logger} [logger] - logger instance, default is `ctx.logger`
167
- * @function App#notExpectLog
168
- */
169
- notExpectLog(str: string | RegExp, logger?: string | Logger): void;
170
- backgroundTasksFinished(): Promise<void>;
171
- get _backgroundTasks(): Promise<any>[];
172
- set _backgroundTasks(tasks: Promise<any>[]);
26
+ export default abstract class ApplicationUnittest extends Application {
27
+ [key: string]: any;
28
+ options: MockOptions & Application['options'];
29
+ _mockHttpClient?: MockHttpClientMethod;
30
+ agent: NonNullable<Application['agent']>;
31
+ /**
32
+ * mock Context
33
+ * @function App#mockContext
34
+ * @param {Object} data - ctx data
35
+ * @param {Object} [options] - mock ctx options
36
+ * @example
37
+ * ```js
38
+ * const ctx = app.mockContext({
39
+ * user: {
40
+ * name: 'Jason'
41
+ * }
42
+ * });
43
+ * console.log(ctx.user.name); // Jason
44
+ *
45
+ * // controller
46
+ * module.exports = function*() {
47
+ * this.body = this.user.name;
48
+ * };
49
+ * ```
50
+ */
51
+ mockContext(data?: MockContextData, options?: MockContextOptions): MockContext;
52
+ mockContextScope(fn: (ctx?: MockContext) => Promise<any>, data?: MockContextData): Promise<any>;
53
+ /**
54
+ * mock cookie session
55
+ * @function App#mockSession
56
+ * @param {Object} data - session object
57
+ */
58
+ mockSession(data: any): this;
59
+ /**
60
+ * Mock service
61
+ * @function App#mockService
62
+ * @param {String} service - name
63
+ * @param {String} methodName - method
64
+ * @param {Object|Function|Error} fn - mock you data
65
+ */
66
+ mockService(service: string | any, methodName: string, fn: any): this;
67
+ /**
68
+ * mock service that return error
69
+ * @function App#mockServiceError
70
+ * @param {String} service - name
71
+ * @param {String} methodName - method
72
+ * @param {Error} [err] - error information
73
+ */
74
+ mockServiceError(service: string | any, methodName: string, err?: string | Error): this;
75
+ _mockFn(obj: any, name: string, data: any): void;
76
+ /**
77
+ * mock request
78
+ * @function App#mockRequest
79
+ * @param {Request} req - mock request
80
+ */
81
+ mockRequest(req: MockContextData): IncomingMessage;
82
+ /**
83
+ * mock cookies
84
+ * @function App#mockCookies
85
+ */
86
+ mockCookies(cookies: Record<string, string | string[]>): this;
87
+ /**
88
+ * mock header
89
+ * @function App#mockHeaders
90
+ */
91
+ mockHeaders(headers: Record<string, string | string[]>): this;
92
+ /**
93
+ * mock csrf
94
+ * @function App#mockCsrf
95
+ * @since 1.11
96
+ */
97
+ mockCsrf(): this;
98
+ /**
99
+ * mock httpclient
100
+ * @alias mockHttpClient
101
+ * @function App#mockHttpclient
102
+ */
103
+ mockHttpclient(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): this;
104
+ /**
105
+ * mock httpclient
106
+ * @function App#mockHttpClient
107
+ */
108
+ mockHttpClient(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): this;
109
+ /**
110
+ * @deprecated Please use app.mockHttpClient instead of app.mockUrllib
111
+ */
112
+ mockUrllib(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): this;
113
+ /**
114
+ * get mock httpclient agent
115
+ * @function App#mockHttpclientAgent
116
+ */
117
+ mockAgent(): MockAgent;
118
+ mockAgentRestore(): Promise<void>;
119
+ /**
120
+ * @see mm#restore
121
+ * @function App#mockRestore
122
+ */
123
+ mockRestore(): Promise<void>;
124
+ /**
125
+ * @see mm
126
+ * @function App#mm
127
+ */
128
+ get mm(): typeof mock;
129
+ /**
130
+ * override loadAgent
131
+ * @function App#loadAgent
132
+ */
133
+ loadAgent(): void;
134
+ /**
135
+ * mock serverEnv
136
+ * @function App#mockEnv
137
+ * @param {String} env - serverEnv
138
+ */
139
+ mockEnv(env: string): this;
140
+ /**
141
+ * http request helper
142
+ * @function App#httpRequest
143
+ * @return {SupertestRequest} req - supertest request
144
+ * @see https://github.com/visionmedia/supertest
145
+ */
146
+ httpRequest(): EggTestRequest;
147
+ /**
148
+ * collection logger message, then can be use on `expectLog()`
149
+ * @param {String|Logger} [logger] - logger instance, default is `app.logger`
150
+ * @function App#mockLog
151
+ */
152
+ mockLog(logger?: string | Logger): void;
153
+ __checkExpectLog(expectOrNot: boolean, str: string | RegExp, logger?: string | Logger): void;
154
+ /**
155
+ * expect str/regexp in the logger, if your server disk is slow, please call `mockLog()` first.
156
+ * @param {String|RegExp} str - test str or regexp
157
+ * @param {String|Logger} [logger] - logger instance, default is `ctx.logger`
158
+ * @function App#expectLog
159
+ */
160
+ expectLog(str: string | RegExp, logger?: string | Logger): void;
161
+ /**
162
+ * not expect str/regexp in the logger, if your server disk is slow, please call `mockLog()` first.
163
+ * @param {String|RegExp} str - test str or regexp
164
+ * @param {String|Logger} [logger] - logger instance, default is `ctx.logger`
165
+ * @function App#notExpectLog
166
+ */
167
+ notExpectLog(str: string | RegExp, logger?: string | Logger): void;
168
+ backgroundTasksFinished(): Promise<void>;
169
+ get _backgroundTasks(): Promise<any>[];
170
+ set _backgroundTasks(tasks: Promise<any>[]);
173
171
  }
174
- //#endregion
175
- export { MockContext, MockContextData, MockContextOptions, ApplicationUnittest as default };