@eggjs/mock 6.0.7 → 6.1.0-beta.11
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 +36 -57
- package/README.zh_CN.md +31 -51
- package/dist/_virtual/rolldown_runtime.js +7 -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 +34 -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 +10 -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/register.d.ts +10 -0
- package/dist/register.js +40 -0
- package/dist/typings/index.d.ts +1 -0
- package/package.json +69 -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
|
@@ -1,55 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
import { MockHttpClientMethod, MockResponseCallbackOptions, MockResultFunction, MockResultOptions, ResultObject } from "./mock_httpclient.js";
|
|
2
|
+
import { MockAgent } from "urllib";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/types.d.ts
|
|
5
|
+
interface MockOptions {
|
|
2
6
|
/**
|
|
3
7
|
* The directory of the application
|
|
4
8
|
*/
|
|
5
9
|
baseDir?: string;
|
|
6
|
-
|
|
7
10
|
/**
|
|
8
11
|
* Custom you plugins
|
|
9
12
|
*/
|
|
10
13
|
plugins?: any;
|
|
11
|
-
|
|
12
14
|
/**
|
|
13
15
|
* The directory of the egg framework
|
|
14
16
|
*
|
|
15
17
|
* Set to `true` to use the current directory as framework directory
|
|
16
18
|
*/
|
|
17
19
|
framework?: string | boolean;
|
|
18
|
-
|
|
19
20
|
/**
|
|
20
21
|
* current test on plugin
|
|
21
22
|
*/
|
|
22
23
|
plugin?: boolean;
|
|
23
|
-
|
|
24
24
|
/**
|
|
25
|
-
* @deprecated please use framework instead
|
|
25
|
+
* @deprecated please use `framework` instead
|
|
26
26
|
*/
|
|
27
27
|
customEgg?: string | boolean;
|
|
28
|
-
|
|
29
28
|
/**
|
|
30
29
|
* Cache application based on baseDir
|
|
31
30
|
*/
|
|
32
31
|
cache?: boolean;
|
|
33
|
-
|
|
34
32
|
/**
|
|
35
33
|
* Switch on process coverage, but it'll be slower
|
|
36
34
|
*/
|
|
37
35
|
coverage?: boolean;
|
|
38
|
-
|
|
39
36
|
/**
|
|
40
37
|
* Remove $baseDir/logs and $baseDir/run before start, default is `true`
|
|
41
38
|
*/
|
|
42
39
|
clean?: boolean;
|
|
43
|
-
|
|
44
40
|
/**
|
|
45
41
|
* default options.mockCtxStorage value on each mockContext
|
|
46
42
|
*/
|
|
47
43
|
mockCtxStorage?: boolean;
|
|
48
|
-
|
|
49
44
|
beforeInit?: (app: any) => Promise<void>;
|
|
50
45
|
}
|
|
51
|
-
|
|
52
|
-
export interface MockClusterOptions extends MockOptions {
|
|
46
|
+
interface MockClusterOptions extends MockOptions {
|
|
53
47
|
workers?: number | string;
|
|
54
48
|
cache?: boolean;
|
|
55
49
|
port?: number;
|
|
@@ -59,31 +53,20 @@ export interface MockClusterOptions extends MockOptions {
|
|
|
59
53
|
opt?: object;
|
|
60
54
|
startMode?: 'process' | 'worker_threads';
|
|
61
55
|
}
|
|
62
|
-
|
|
63
56
|
/**
|
|
64
57
|
* @deprecated please use MockOptions instead
|
|
65
58
|
* keep this for compatible
|
|
66
59
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export interface MockApplicationOptions extends MockOptions {
|
|
60
|
+
type MockOption = MockOptions;
|
|
61
|
+
interface MockApplicationOptions extends MockOptions {
|
|
70
62
|
baseDir: string;
|
|
71
63
|
framework: string;
|
|
72
64
|
clusterPort?: number;
|
|
73
65
|
}
|
|
74
|
-
|
|
75
|
-
export interface MockClusterApplicationOptions extends MockClusterOptions {
|
|
66
|
+
interface MockClusterApplicationOptions extends MockClusterOptions {
|
|
76
67
|
baseDir: string;
|
|
77
68
|
framework: string;
|
|
78
69
|
port: number;
|
|
79
70
|
}
|
|
80
|
-
|
|
81
|
-
export type
|
|
82
|
-
MockResultOptions, ResultObject,
|
|
83
|
-
MockResponseCallbackOptions, MockResultFunction,
|
|
84
|
-
MockHttpClientMethod,
|
|
85
|
-
} from './mock_httpclient.js';
|
|
86
|
-
|
|
87
|
-
export type {
|
|
88
|
-
MockAgent,
|
|
89
|
-
} from 'urllib';
|
|
71
|
+
//#endregion
|
|
72
|
+
export { type MockAgent, MockApplicationOptions, MockClusterApplicationOptions, MockClusterOptions, type MockHttpClientMethod, MockOption, MockOptions, type MockResponseCallbackOptions, type MockResultFunction, type MockResultOptions, type ResultObject };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/lib/utils.d.ts
|
|
2
|
+
declare function getSourceDirname(): string;
|
|
3
|
+
declare function sleep(delay: number): Promise<void>;
|
|
4
|
+
declare function rimraf(filepath: string): Promise<void>;
|
|
5
|
+
declare function rimrafSync(filepath: string): void;
|
|
6
|
+
declare function getProperty(target: any, prop: PropertyKey): any;
|
|
7
|
+
declare function getEggOptions(): {
|
|
8
|
+
baseDir: string;
|
|
9
|
+
framework: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getEggOptions, getProperty, getSourceDirname, rimraf, rimrafSync, sleep };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { rmSync } from "node:fs";
|
|
3
|
+
import { rm } from "node:fs/promises";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { scheduler } from "node:timers/promises";
|
|
6
|
+
|
|
7
|
+
//#region src/lib/utils.ts
|
|
8
|
+
function getSourceDirname() {
|
|
9
|
+
if (typeof __dirname !== "undefined") return path.dirname(__dirname);
|
|
10
|
+
return path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
11
|
+
}
|
|
12
|
+
async function sleep(delay) {
|
|
13
|
+
await scheduler.wait(delay);
|
|
14
|
+
}
|
|
15
|
+
async function rimraf(filepath) {
|
|
16
|
+
await rm(filepath, {
|
|
17
|
+
force: true,
|
|
18
|
+
recursive: true
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function rimrafSync(filepath) {
|
|
22
|
+
rmSync(filepath, {
|
|
23
|
+
force: true,
|
|
24
|
+
recursive: true
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function getProperty(target, prop) {
|
|
28
|
+
const member = target[prop];
|
|
29
|
+
if (typeof member === "function") return member.bind(target);
|
|
30
|
+
return member;
|
|
31
|
+
}
|
|
32
|
+
function getEggOptions() {
|
|
33
|
+
return {
|
|
34
|
+
baseDir: process.env.EGG_BASE_DIR ?? process.cwd(),
|
|
35
|
+
framework: process.env.EGG_FRAMEWORK
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { getEggOptions, getProperty, getSourceDirname, rimraf, rimrafSync, sleep };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/register.d.ts
|
|
2
|
+
declare function mochaGlobalSetup(): Promise<void>;
|
|
3
|
+
declare function mochaGlobalTeardown(): Promise<void>;
|
|
4
|
+
declare const mochaHooks: {
|
|
5
|
+
beforeAll(): Promise<void>;
|
|
6
|
+
afterEach(): Promise<void>;
|
|
7
|
+
afterAll(): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { mochaGlobalSetup, mochaGlobalTeardown, mochaHooks };
|
package/dist/register.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { closeAgent, setupAgent } from "./lib/agent_handler.js";
|
|
2
|
+
import { getApp } from "./lib/app_handler.js";
|
|
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");
|
|
13
|
+
}
|
|
14
|
+
async function mochaGlobalTeardown() {
|
|
15
|
+
debug("mochaGlobalTeardown, agent.closeAgent() start");
|
|
16
|
+
await closeAgent();
|
|
17
|
+
debug("mochaGlobalTeardown, agent.closeAgent() end");
|
|
18
|
+
}
|
|
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
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { mochaGlobalSetup, mochaGlobalTeardown, mochaHooks };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "egg";
|
package/package.json
CHANGED
|
@@ -1,136 +1,107 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/mock",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.1.0-beta.11",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"eggPlugin": {
|
|
8
|
-
"name": "egg-mock"
|
|
9
|
-
"exports": {
|
|
10
|
-
"import": "./dist/esm",
|
|
11
|
-
"require": "./dist/commonjs"
|
|
12
|
-
}
|
|
8
|
+
"name": "egg-mock"
|
|
13
9
|
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./dist/index.js",
|
|
16
|
+
"./app": "./dist/app.js",
|
|
17
|
+
"./app/extend/agent": "./dist/app/extend/agent.js",
|
|
18
|
+
"./app/extend/application": "./dist/app/extend/application.js",
|
|
19
|
+
"./app/middleware/cluster_app_mock": "./dist/app/middleware/cluster_app_mock.js",
|
|
20
|
+
"./bootstrap": "./dist/bootstrap.js",
|
|
21
|
+
"./inject_mocha": "./dist/inject_mocha.js",
|
|
22
|
+
"./lib/agent_handler": "./dist/lib/agent_handler.js",
|
|
23
|
+
"./lib/app": "./dist/lib/app.js",
|
|
24
|
+
"./lib/app_handler": "./dist/lib/app_handler.js",
|
|
25
|
+
"./lib/cluster": "./dist/lib/cluster.js",
|
|
26
|
+
"./lib/context": "./dist/lib/context.js",
|
|
27
|
+
"./lib/format_options": "./dist/lib/format_options.js",
|
|
28
|
+
"./lib/inject_context": "./dist/lib/inject_context.js",
|
|
29
|
+
"./lib/mock_agent": "./dist/lib/mock_agent.js",
|
|
30
|
+
"./lib/mock_custom_loader": "./dist/lib/mock_custom_loader.js",
|
|
31
|
+
"./lib/mock_http_server": "./dist/lib/mock_http_server.js",
|
|
32
|
+
"./lib/mock_httpclient": "./dist/lib/mock_httpclient.js",
|
|
33
|
+
"./lib/parallel/agent": "./dist/lib/parallel/agent.js",
|
|
34
|
+
"./lib/parallel/app": "./dist/lib/parallel/app.js",
|
|
35
|
+
"./lib/parallel/util": "./dist/lib/parallel/util.js",
|
|
36
|
+
"./lib/prerequire": "./dist/lib/prerequire.js",
|
|
37
|
+
"./lib/request_call_function": "./dist/lib/request_call_function.js",
|
|
38
|
+
"./lib/restore": "./dist/lib/restore.js",
|
|
39
|
+
"./lib/start-cluster": "./dist/lib/start-cluster.js",
|
|
40
|
+
"./lib/supertest": "./dist/lib/supertest.js",
|
|
41
|
+
"./lib/tmp/empty": "./dist/lib/tmp/empty.js",
|
|
42
|
+
"./lib/types": "./dist/lib/types.js",
|
|
43
|
+
"./lib/utils": "./dist/lib/utils.js",
|
|
44
|
+
"./register": "./dist/register.js",
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"dist"
|
|
49
|
+
],
|
|
14
50
|
"description": "mock server plugin for egg",
|
|
15
|
-
"homepage": "https://github.com/eggjs/mock",
|
|
16
51
|
"repository": {
|
|
17
52
|
"type": "git",
|
|
18
|
-
"url": "git
|
|
53
|
+
"url": "git://github.com/eggjs/egg.git",
|
|
54
|
+
"directory": "packages/mock"
|
|
19
55
|
},
|
|
20
56
|
"bugs": {
|
|
21
57
|
"url": "https://github.com/eggjs/egg/issues"
|
|
22
58
|
},
|
|
59
|
+
"homepage": "https://github.com/eggjs/egg/tree/next/packages/mock",
|
|
23
60
|
"keywords": [
|
|
24
61
|
"egg",
|
|
25
62
|
"mock"
|
|
26
63
|
],
|
|
27
64
|
"author": "popomore <sakura9515@gmail.com>",
|
|
28
65
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
66
|
+
"node": ">= 20.19.0"
|
|
30
67
|
},
|
|
31
68
|
"dependencies": {
|
|
32
|
-
"
|
|
33
|
-
"@eggjs/supertest": "^8.1.0",
|
|
34
|
-
"@eggjs/utils": "^4.0.3",
|
|
35
|
-
"coffee": "^5.2.1",
|
|
69
|
+
"coffee": "5",
|
|
36
70
|
"detect-port": "^2.1.0",
|
|
37
71
|
"egg-logger": "^3.5.0",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"globby": "^11.1.0",
|
|
72
|
+
"get-ready": "^3.1.0",
|
|
73
|
+
"globby": "^11.0.2",
|
|
41
74
|
"is-type-of": "^2.2.0",
|
|
42
75
|
"merge-descriptors": "^2.0.0",
|
|
43
|
-
"mm": "^4.0.
|
|
44
|
-
"sdk-base": "^5.0.
|
|
76
|
+
"mm": "^4.0.2",
|
|
77
|
+
"sdk-base": "^5.0.1",
|
|
45
78
|
"urllib": "^4.6.11",
|
|
46
|
-
"utility": "^2.
|
|
79
|
+
"utility": "^2.5.0",
|
|
80
|
+
"@eggjs/utils": "4.5.0-beta.11",
|
|
81
|
+
"@eggjs/extend2": "4.1.0-beta.11",
|
|
82
|
+
"@eggjs/supertest": "8.3.0-beta.11"
|
|
47
83
|
},
|
|
48
84
|
"peerDependencies": {
|
|
49
|
-
"
|
|
85
|
+
"egg": "4.1.0-beta.11"
|
|
50
86
|
},
|
|
51
87
|
"devDependencies": {
|
|
52
|
-
"@arethetypeswrong/cli": "^0.17.1",
|
|
53
|
-
"@eggjs/bin": "^7.0.0",
|
|
54
88
|
"@eggjs/tegg": "^3.2.2",
|
|
55
89
|
"@eggjs/tegg-config": "^3.2.2",
|
|
56
90
|
"@eggjs/tegg-controller-plugin": "^3.2.2",
|
|
57
91
|
"@eggjs/tegg-plugin": "^3.2.2",
|
|
58
|
-
"@eggjs/tsconfig": "1",
|
|
59
92
|
"@types/methods": "^1.1.4",
|
|
60
|
-
"@types/
|
|
61
|
-
"
|
|
62
|
-
"egg": "^
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"mocha": "^11.0.1",
|
|
68
|
-
"pedding": "^2.0.0",
|
|
69
|
-
"rimraf": "6",
|
|
70
|
-
"tsd": "^0.31.2",
|
|
71
|
-
"tshy": "3",
|
|
72
|
-
"tshy-after": "^1.3.1",
|
|
73
|
-
"typescript": "5"
|
|
93
|
+
"@types/node": "24.5.2",
|
|
94
|
+
"egg-errors": "^2.3.2",
|
|
95
|
+
"egg-tracer": "^2.1.0",
|
|
96
|
+
"pedding": "^2.0.1",
|
|
97
|
+
"tsd": "^0.33.0",
|
|
98
|
+
"tsdown": "^0.15.4",
|
|
99
|
+
"typescript": "5.9.2"
|
|
74
100
|
},
|
|
75
101
|
"scripts": {
|
|
76
|
-
"
|
|
77
|
-
"lint": "
|
|
78
|
-
"
|
|
79
|
-
"test": "
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"preci": "npm run clean && npm run lint && npm run prepublishOnly",
|
|
83
|
-
"ci": "egg-bin test",
|
|
84
|
-
"postci": "npm run clean",
|
|
85
|
-
"prepublishOnly": "tshy && tshy-after && attw --pack --profile node16"
|
|
86
|
-
},
|
|
87
|
-
"type": "module",
|
|
88
|
-
"tshy": {
|
|
89
|
-
"exports": {
|
|
90
|
-
".": "./src/index.ts",
|
|
91
|
-
"./bootstrap": "./src/bootstrap.ts",
|
|
92
|
-
"./register": "./src/register.ts",
|
|
93
|
-
"./package.json": "./package.json"
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
"exports": {
|
|
97
|
-
".": {
|
|
98
|
-
"import": {
|
|
99
|
-
"types": "./dist/esm/index.d.ts",
|
|
100
|
-
"default": "./dist/esm/index.js"
|
|
101
|
-
},
|
|
102
|
-
"require": {
|
|
103
|
-
"types": "./dist/commonjs/index.d.ts",
|
|
104
|
-
"default": "./dist/commonjs/index.js"
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
"./bootstrap": {
|
|
108
|
-
"import": {
|
|
109
|
-
"types": "./dist/esm/bootstrap.d.ts",
|
|
110
|
-
"default": "./dist/esm/bootstrap.js"
|
|
111
|
-
},
|
|
112
|
-
"require": {
|
|
113
|
-
"types": "./dist/commonjs/bootstrap.d.ts",
|
|
114
|
-
"default": "./dist/commonjs/bootstrap.js"
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
"./register": {
|
|
118
|
-
"import": {
|
|
119
|
-
"types": "./dist/esm/register.d.ts",
|
|
120
|
-
"default": "./dist/esm/register.js"
|
|
121
|
-
},
|
|
122
|
-
"require": {
|
|
123
|
-
"types": "./dist/commonjs/register.d.ts",
|
|
124
|
-
"default": "./dist/commonjs/register.js"
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
"./package.json": "./package.json"
|
|
128
|
-
},
|
|
129
|
-
"files": [
|
|
130
|
-
"dist",
|
|
131
|
-
"src"
|
|
132
|
-
],
|
|
133
|
-
"types": "./dist/commonjs/index.d.ts",
|
|
134
|
-
"main": "./dist/commonjs/index.js",
|
|
135
|
-
"module": "./dist/esm/index.js"
|
|
136
|
-
}
|
|
102
|
+
"build": "tsdown",
|
|
103
|
+
"lint": "oxlint",
|
|
104
|
+
"typecheck": "tsc --noEmit",
|
|
105
|
+
"test": "vitest run"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { mock, restore } from 'mm';
|
|
2
|
-
import { EggCore } from '@eggjs/core';
|
|
3
|
-
import { MockResultFunction, MockResultOptions, MockHttpClientMethod } from '../../lib/mock_httpclient.js';
|
|
4
|
-
export default abstract class AgentUnittest extends EggCore {
|
|
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;
|
|
34
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const mm_1 = require("mm");
|
|
4
|
-
const core_1 = require("@eggjs/core");
|
|
5
|
-
const mock_httpclient_js_1 = require("../../lib/mock_httpclient.js");
|
|
6
|
-
const mock_agent_js_1 = require("../../lib/mock_agent.js");
|
|
7
|
-
class AgentUnittest extends core_1.EggCore {
|
|
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) {
|
|
23
|
-
this._mockHttpClient = (0, mock_httpclient_js_1.createMockHttpClient)(this);
|
|
24
|
-
}
|
|
25
|
-
return this._mockHttpClient(mockUrl, mockMethod, mockResult);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* get mock httpclient agent
|
|
29
|
-
* @function Agent#mockHttpclientAgent
|
|
30
|
-
*/
|
|
31
|
-
mockAgent() {
|
|
32
|
-
return (0, mock_agent_js_1.getMockAgent)(this);
|
|
33
|
-
}
|
|
34
|
-
async mockAgentRestore() {
|
|
35
|
-
await (0, mock_agent_js_1.restoreMockAgent)();
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* @see mm#restore
|
|
39
|
-
* @function Agent#mockRestore
|
|
40
|
-
*/
|
|
41
|
-
mockRestore = mm_1.restore;
|
|
42
|
-
/**
|
|
43
|
-
* @see mm
|
|
44
|
-
* @function Agent#mm
|
|
45
|
-
*/
|
|
46
|
-
mm = mm_1.mock;
|
|
47
|
-
}
|
|
48
|
-
exports.default = AgentUnittest;
|
|
49
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWdlbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL2V4dGVuZC9hZ2VudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDJCQUFtQztBQUNuQyxzQ0FBc0M7QUFDdEMscUVBSXNDO0FBQ3RDLDJEQUF5RTtBQUV6RSxNQUE4QixhQUFjLFNBQVEsY0FBTztJQUV6RCxlQUFlLENBQXVCO0lBRXRDOzs7O09BSUc7SUFDSCxjQUFjLENBQUMsT0FBd0IsRUFBRSxVQUFzRSxFQUFFLFVBQTREO1FBQzNLLE9BQU8sSUFBSSxDQUFDLGNBQWMsQ0FBQyxPQUFPLEVBQUUsVUFBVSxFQUFFLFVBQVUsQ0FBQyxDQUFDO0lBQzlELENBQUM7SUFFRDs7O09BR0c7SUFDSCxjQUFjLENBQUMsT0FBd0IsRUFBRSxVQUFzRSxFQUFFLFVBQTREO1FBQzNLLElBQUksQ0FBQyxJQUFJLENBQUMsZUFBZSxFQUFFLENBQUM7WUFDMUIsSUFBSSxDQUFDLGVBQWUsR0FBRyxJQUFBLHlDQUFvQixFQUFDLElBQUksQ0FBQyxDQUFDO1FBQ3BELENBQUM7UUFDRCxPQUFPLElBQUksQ0FBQyxlQUFlLENBQUMsT0FBTyxFQUFFLFVBQVUsRUFBRSxVQUFVLENBQUMsQ0FBQztJQUMvRCxDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsU0FBUztRQUNQLE9BQU8sSUFBQSw0QkFBWSxFQUFDLElBQVcsQ0FBQyxDQUFDO0lBQ25DLENBQUM7SUFFRCxLQUFLLENBQUMsZ0JBQWdCO1FBQ3BCLE1BQU0sSUFBQSxnQ0FBZ0IsR0FBRSxDQUFDO0lBQzNCLENBQUM7SUFFRDs7O09BR0c7SUFDSCxXQUFXLEdBQUcsWUFBTyxDQUFDO0lBRXRCOzs7T0FHRztJQUNILEVBQUUsR0FBRyxTQUFJLENBQUM7Q0FDWDtBQS9DRCxnQ0ErQ0MifQ==
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage } from 'node:http';
|
|
2
|
-
import { mock } from 'mm';
|
|
3
|
-
import type { HttpClient } from 'urllib';
|
|
4
|
-
import { Logger } from 'egg-logger';
|
|
5
|
-
import { EggCore, type EggCoreOptions, type Context as EggCoreContext } from '@eggjs/core';
|
|
6
|
-
import type { Context as EggContext } from 'egg';
|
|
7
|
-
import { MockResultFunction, MockResultOptions, MockHttpClientMethod } from '../../lib/mock_httpclient.js';
|
|
8
|
-
import { EggTestRequest } from '../../lib/supertest.js';
|
|
9
|
-
import { MockOptions } from '../../lib/types.js';
|
|
10
|
-
export interface MockContextOptions {
|
|
11
|
-
/**
|
|
12
|
-
* mock ctxStorage or not, default is `true`
|
|
13
|
-
*/
|
|
14
|
-
mockCtxStorage?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* reuse ctxStorage or not, default is `true`
|
|
17
|
-
*/
|
|
18
|
-
reuseCtxStorage?: boolean;
|
|
19
|
-
}
|
|
20
|
-
export interface MockContextData {
|
|
21
|
-
headers?: Record<string, string | string[]>;
|
|
22
|
-
[key: string]: any;
|
|
23
|
-
}
|
|
24
|
-
export interface MockContext extends EggContext, EggCoreContext {
|
|
25
|
-
service: any;
|
|
26
|
-
}
|
|
27
|
-
export default abstract class ApplicationUnittest extends EggCore {
|
|
28
|
-
[key: string]: any;
|
|
29
|
-
options: MockOptions & EggCoreOptions;
|
|
30
|
-
_mockHttpClient?: MockHttpClientMethod;
|
|
31
|
-
httpclient: HttpClient;
|
|
32
|
-
/**
|
|
33
|
-
* mock Context
|
|
34
|
-
* @function App#mockContext
|
|
35
|
-
* @param {Object} data - ctx data
|
|
36
|
-
* @param {Object} [options] - mock ctx options
|
|
37
|
-
* @example
|
|
38
|
-
* ```js
|
|
39
|
-
* const ctx = app.mockContext({
|
|
40
|
-
* user: {
|
|
41
|
-
* name: 'Jason'
|
|
42
|
-
* }
|
|
43
|
-
* });
|
|
44
|
-
* console.log(ctx.user.name); // Jason
|
|
45
|
-
*
|
|
46
|
-
* // controller
|
|
47
|
-
* module.exports = function*() {
|
|
48
|
-
* this.body = this.user.name;
|
|
49
|
-
* };
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
mockContext(data?: MockContextData, options?: MockContextOptions): MockContext;
|
|
53
|
-
mockContextScope(fn: (ctx?: MockContext) => Promise<any>, data?: MockContextData): Promise<any>;
|
|
54
|
-
/**
|
|
55
|
-
* mock cookie session
|
|
56
|
-
* @function App#mockSession
|
|
57
|
-
* @param {Object} data - session object
|
|
58
|
-
*/
|
|
59
|
-
mockSession(data: any): this;
|
|
60
|
-
/**
|
|
61
|
-
* Mock service
|
|
62
|
-
* @function App#mockService
|
|
63
|
-
* @param {String} service - name
|
|
64
|
-
* @param {String} methodName - method
|
|
65
|
-
* @param {Object|Function|Error} fn - mock you data
|
|
66
|
-
*/
|
|
67
|
-
mockService(service: string | any, methodName: string, fn: any): this;
|
|
68
|
-
/**
|
|
69
|
-
* mock service that return error
|
|
70
|
-
* @function App#mockServiceError
|
|
71
|
-
* @param {String} service - name
|
|
72
|
-
* @param {String} methodName - method
|
|
73
|
-
* @param {Error} [err] - error information
|
|
74
|
-
*/
|
|
75
|
-
mockServiceError(service: string | any, methodName: string, err?: string | Error): this;
|
|
76
|
-
_mockFn(obj: any, name: string, data: any): void;
|
|
77
|
-
/**
|
|
78
|
-
* mock request
|
|
79
|
-
* @function App#mockRequest
|
|
80
|
-
* @param {Request} req - mock request
|
|
81
|
-
*/
|
|
82
|
-
mockRequest(req: MockContextData): IncomingMessage;
|
|
83
|
-
/**
|
|
84
|
-
* mock cookies
|
|
85
|
-
* @function App#mockCookies
|
|
86
|
-
*/
|
|
87
|
-
mockCookies(cookies: Record<string, string | string[]>): this;
|
|
88
|
-
/**
|
|
89
|
-
* mock header
|
|
90
|
-
* @function App#mockHeaders
|
|
91
|
-
*/
|
|
92
|
-
mockHeaders(headers: Record<string, string | string[]>): this;
|
|
93
|
-
/**
|
|
94
|
-
* mock csrf
|
|
95
|
-
* @function App#mockCsrf
|
|
96
|
-
* @since 1.11
|
|
97
|
-
*/
|
|
98
|
-
mockCsrf(): this;
|
|
99
|
-
/**
|
|
100
|
-
* mock httpclient
|
|
101
|
-
* @alias mockHttpClient
|
|
102
|
-
* @function App#mockHttpclient
|
|
103
|
-
*/
|
|
104
|
-
mockHttpclient(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): this;
|
|
105
|
-
/**
|
|
106
|
-
* mock httpclient
|
|
107
|
-
* @function App#mockHttpClient
|
|
108
|
-
*/
|
|
109
|
-
mockHttpClient(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): this;
|
|
110
|
-
/**
|
|
111
|
-
* @deprecated Please use app.mockHttpClient instead of app.mockUrllib
|
|
112
|
-
*/
|
|
113
|
-
mockUrllib(mockUrl: string | RegExp, mockMethod: string | string[] | MockResultOptions | MockResultFunction, mockResult?: MockResultOptions | MockResultFunction | string): this;
|
|
114
|
-
/**
|
|
115
|
-
* get mock httpclient agent
|
|
116
|
-
* @function App#mockHttpclientAgent
|
|
117
|
-
*/
|
|
118
|
-
mockAgent(): import("urllib").MockAgent<import("urllib").MockAgent.Options>;
|
|
119
|
-
mockAgentRestore(): Promise<void>;
|
|
120
|
-
/**
|
|
121
|
-
* @see mm#restore
|
|
122
|
-
* @function App#mockRestore
|
|
123
|
-
*/
|
|
124
|
-
mockRestore(): Promise<void>;
|
|
125
|
-
/**
|
|
126
|
-
* @see mm
|
|
127
|
-
* @function App#mm
|
|
128
|
-
*/
|
|
129
|
-
get mm(): typeof mock;
|
|
130
|
-
/**
|
|
131
|
-
* override loadAgent
|
|
132
|
-
* @function App#loadAgent
|
|
133
|
-
*/
|
|
134
|
-
loadAgent(): void;
|
|
135
|
-
/**
|
|
136
|
-
* mock serverEnv
|
|
137
|
-
* @function App#mockEnv
|
|
138
|
-
* @param {String} env - serverEnv
|
|
139
|
-
*/
|
|
140
|
-
mockEnv(env: string): this;
|
|
141
|
-
/**
|
|
142
|
-
* http request helper
|
|
143
|
-
* @function App#httpRequest
|
|
144
|
-
* @return {SupertestRequest} req - supertest request
|
|
145
|
-
* @see https://github.com/visionmedia/supertest
|
|
146
|
-
*/
|
|
147
|
-
httpRequest(): EggTestRequest;
|
|
148
|
-
/**
|
|
149
|
-
* collection logger message, then can be use on `expectLog()`
|
|
150
|
-
* @param {String|Logger} [logger] - logger instance, default is `app.logger`
|
|
151
|
-
* @function App#mockLog
|
|
152
|
-
*/
|
|
153
|
-
mockLog(logger?: string | Logger): void;
|
|
154
|
-
__checkExpectLog(expectOrNot: boolean, str: string | RegExp, logger?: string | Logger): void;
|
|
155
|
-
/**
|
|
156
|
-
* expect str/regexp in the logger, if your server disk is slow, please call `mockLog()` first.
|
|
157
|
-
* @param {String|RegExp} str - test str or regexp
|
|
158
|
-
* @param {String|Logger} [logger] - logger instance, default is `ctx.logger`
|
|
159
|
-
* @function App#expectLog
|
|
160
|
-
*/
|
|
161
|
-
expectLog(str: string | RegExp, logger?: string | Logger): void;
|
|
162
|
-
/**
|
|
163
|
-
* not expect str/regexp in the logger, if your server disk is slow, please call `mockLog()` first.
|
|
164
|
-
* @param {String|RegExp} str - test str or regexp
|
|
165
|
-
* @param {String|Logger} [logger] - logger instance, default is `ctx.logger`
|
|
166
|
-
* @function App#notExpectLog
|
|
167
|
-
*/
|
|
168
|
-
notExpectLog(str: string | RegExp, logger?: string | Logger): void;
|
|
169
|
-
backgroundTasksFinished(): Promise<void>;
|
|
170
|
-
get _backgroundTasks(): Promise<any>[];
|
|
171
|
-
set _backgroundTasks(tasks: Promise<any>[]);
|
|
172
|
-
}
|