@tramvai/test-integration 2.22.0 → 2.24.3
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/lib/app/papi.d.ts +14 -5
- package/lib/app/startCli.d.ts +17 -6
- package/lib/app/startCliFakeApp.d.ts +17 -6
- package/lib/app/startCliRealApp.d.ts +17 -6
- package/lib/index.es.js +18 -15
- package/lib/index.js +18 -16
- package/package.json +4 -4
package/lib/app/papi.d.ts
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import supertest from 'supertest';
|
|
2
1
|
interface Options {
|
|
3
2
|
serverUrl: string;
|
|
4
3
|
appName: string;
|
|
5
4
|
}
|
|
6
5
|
export declare const wrapPapi: ({ serverUrl, appName }: Options) => {
|
|
7
|
-
publicPapi:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
publicPapi: (path: string, { method, body, contentType, headers, }?: {
|
|
7
|
+
method?: "get" | "post" | "put" | "delete" | undefined;
|
|
8
|
+
body?: Record<string, any> | undefined;
|
|
9
|
+
contentType?: "json" | "form" | undefined;
|
|
10
|
+
headers?: Record<string, string> | undefined;
|
|
11
|
+
} | undefined) => import("supertest").Test;
|
|
12
|
+
privatePapi: (path: string, { method, body, contentType, headers, }?: {
|
|
13
|
+
method?: "get" | "post" | "put" | "delete" | undefined;
|
|
14
|
+
body?: Record<string, any> | undefined;
|
|
15
|
+
contentType?: "json" | "form" | undefined;
|
|
16
|
+
headers?: Record<string, string> | undefined;
|
|
17
|
+
} | undefined) => import("supertest").Test;
|
|
18
|
+
clearCache: () => import("supertest").Test;
|
|
19
|
+
bundleInfo: () => import("supertest").Test;
|
|
11
20
|
};
|
|
12
21
|
export {};
|
package/lib/app/startCli.d.ts
CHANGED
|
@@ -12,10 +12,11 @@ export declare const startCli: (targetOrConfig: StartOptions['target'] | StartOp
|
|
|
12
12
|
staticUrl: string;
|
|
13
13
|
stdout: Writable;
|
|
14
14
|
stderr: Writable;
|
|
15
|
-
request: (path: string, { method, body, contentType, }?: {
|
|
16
|
-
method?: "get" | "post" | "put" | undefined;
|
|
15
|
+
request: (path: string, { method, body, contentType, headers, }?: {
|
|
16
|
+
method?: "get" | "post" | "put" | "delete" | undefined;
|
|
17
17
|
body?: Record<string, any> | undefined;
|
|
18
18
|
contentType?: "json" | "form" | undefined;
|
|
19
|
+
headers?: Record<string, string> | undefined;
|
|
19
20
|
} | undefined) => import("supertest").Test;
|
|
20
21
|
render: (path: string, { method, parserOptions, }?: {
|
|
21
22
|
method?: "get" | "post" | "put" | undefined;
|
|
@@ -28,8 +29,18 @@ export declare const startCli: (targetOrConfig: StartOptions['target'] | StartOp
|
|
|
28
29
|
application: string;
|
|
29
30
|
}>;
|
|
30
31
|
papi: {
|
|
31
|
-
publicPapi:
|
|
32
|
-
|
|
32
|
+
publicPapi: (path: string, { method, body, contentType, headers, }?: {
|
|
33
|
+
method?: "get" | "post" | "put" | "delete" | undefined;
|
|
34
|
+
body?: Record<string, any> | undefined;
|
|
35
|
+
contentType?: "json" | "form" | undefined;
|
|
36
|
+
headers?: Record<string, string> | undefined;
|
|
37
|
+
} | undefined) => import("supertest").Test;
|
|
38
|
+
privatePapi: (path: string, { method, body, contentType, headers, }?: {
|
|
39
|
+
method?: "get" | "post" | "put" | "delete" | undefined;
|
|
40
|
+
body?: Record<string, any> | undefined;
|
|
41
|
+
contentType?: "json" | "form" | undefined;
|
|
42
|
+
headers?: Record<string, string> | undefined;
|
|
43
|
+
} | undefined) => import("supertest").Test;
|
|
33
44
|
clearCache: () => import("supertest").Test;
|
|
34
45
|
bundleInfo: () => import("supertest").Test;
|
|
35
46
|
};
|
|
@@ -37,8 +48,8 @@ export declare const startCli: (targetOrConfig: StartOptions['target'] | StartOp
|
|
|
37
48
|
close: (() => Promise<void>) & (() => Promise<void>);
|
|
38
49
|
invalidate: () => Promise<void>;
|
|
39
50
|
getBuildStats: import("@tramvai/cli/lib/typings/build/Builder").GetBuildStats;
|
|
40
|
-
staticServer?: import("http").Server | undefined;
|
|
41
|
-
server?: import("http").Server | undefined;
|
|
51
|
+
staticServer?: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | undefined;
|
|
52
|
+
server?: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | undefined;
|
|
42
53
|
builder: import("@tramvai/cli/lib/typings/build/Builder").Builder<any>;
|
|
43
54
|
}>;
|
|
44
55
|
export declare type StartCliResult = PromiseType<ReturnType<typeof startCli>>;
|
|
@@ -6,10 +6,11 @@ export declare const runFakeApp: (config: Partial<StartOptions['config']>, optio
|
|
|
6
6
|
staticUrl: string;
|
|
7
7
|
stdout: import("stream").Writable;
|
|
8
8
|
stderr: import("stream").Writable;
|
|
9
|
-
request: (path: string, { method, body, contentType, }?: {
|
|
10
|
-
method?: "get" | "post" | "put" | undefined;
|
|
9
|
+
request: (path: string, { method, body, contentType, headers, }?: {
|
|
10
|
+
method?: "get" | "post" | "put" | "delete" | undefined;
|
|
11
11
|
body?: Record<string, any> | undefined;
|
|
12
12
|
contentType?: "json" | "form" | undefined;
|
|
13
|
+
headers?: Record<string, string> | undefined;
|
|
13
14
|
} | undefined) => import("supertest").Test;
|
|
14
15
|
render: (path: string, { method, parserOptions, }?: {
|
|
15
16
|
method?: "get" | "post" | "put" | undefined;
|
|
@@ -22,8 +23,18 @@ export declare const runFakeApp: (config: Partial<StartOptions['config']>, optio
|
|
|
22
23
|
application: string;
|
|
23
24
|
}>;
|
|
24
25
|
papi: {
|
|
25
|
-
publicPapi:
|
|
26
|
-
|
|
26
|
+
publicPapi: (path: string, { method, body, contentType, headers, }?: {
|
|
27
|
+
method?: "get" | "post" | "put" | "delete" | undefined;
|
|
28
|
+
body?: Record<string, any> | undefined;
|
|
29
|
+
contentType?: "json" | "form" | undefined;
|
|
30
|
+
headers?: Record<string, string> | undefined;
|
|
31
|
+
} | undefined) => import("supertest").Test;
|
|
32
|
+
privatePapi: (path: string, { method, body, contentType, headers, }?: {
|
|
33
|
+
method?: "get" | "post" | "put" | "delete" | undefined;
|
|
34
|
+
body?: Record<string, any> | undefined;
|
|
35
|
+
contentType?: "json" | "form" | undefined;
|
|
36
|
+
headers?: Record<string, string> | undefined;
|
|
37
|
+
} | undefined) => import("supertest").Test;
|
|
27
38
|
clearCache: () => import("supertest").Test;
|
|
28
39
|
bundleInfo: () => import("supertest").Test;
|
|
29
40
|
};
|
|
@@ -31,7 +42,7 @@ export declare const runFakeApp: (config: Partial<StartOptions['config']>, optio
|
|
|
31
42
|
close: (() => Promise<void>) & (() => Promise<void>);
|
|
32
43
|
invalidate: () => Promise<void>;
|
|
33
44
|
getBuildStats: import("@tramvai/cli/lib/typings/build/Builder").GetBuildStats;
|
|
34
|
-
staticServer?: import("http").Server | undefined;
|
|
35
|
-
server?: import("http").Server | undefined;
|
|
45
|
+
staticServer?: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | undefined;
|
|
46
|
+
server?: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | undefined;
|
|
36
47
|
builder: import("@tramvai/cli/lib/typings/build/Builder").Builder<any>;
|
|
37
48
|
}>;
|
|
@@ -5,10 +5,11 @@ export declare const runRealApp: (tramvaiConfigRoot: string, appName: string, op
|
|
|
5
5
|
staticUrl: string;
|
|
6
6
|
stdout: import("stream").Writable;
|
|
7
7
|
stderr: import("stream").Writable;
|
|
8
|
-
request: (path: string, { method, body, contentType, }?: {
|
|
9
|
-
method?: "get" | "post" | "put" | undefined;
|
|
8
|
+
request: (path: string, { method, body, contentType, headers, }?: {
|
|
9
|
+
method?: "get" | "post" | "put" | "delete" | undefined;
|
|
10
10
|
body?: Record<string, any> | undefined;
|
|
11
11
|
contentType?: "json" | "form" | undefined;
|
|
12
|
+
headers?: Record<string, string> | undefined;
|
|
12
13
|
} | undefined) => import("supertest").Test;
|
|
13
14
|
render: (path: string, { method, parserOptions, }?: {
|
|
14
15
|
method?: "get" | "post" | "put" | undefined;
|
|
@@ -21,8 +22,18 @@ export declare const runRealApp: (tramvaiConfigRoot: string, appName: string, op
|
|
|
21
22
|
application: string;
|
|
22
23
|
}>;
|
|
23
24
|
papi: {
|
|
24
|
-
publicPapi:
|
|
25
|
-
|
|
25
|
+
publicPapi: (path: string, { method, body, contentType, headers, }?: {
|
|
26
|
+
method?: "get" | "post" | "put" | "delete" | undefined;
|
|
27
|
+
body?: Record<string, any> | undefined;
|
|
28
|
+
contentType?: "json" | "form" | undefined;
|
|
29
|
+
headers?: Record<string, string> | undefined;
|
|
30
|
+
} | undefined) => import("supertest").Test;
|
|
31
|
+
privatePapi: (path: string, { method, body, contentType, headers, }?: {
|
|
32
|
+
method?: "get" | "post" | "put" | "delete" | undefined;
|
|
33
|
+
body?: Record<string, any> | undefined;
|
|
34
|
+
contentType?: "json" | "form" | undefined;
|
|
35
|
+
headers?: Record<string, string> | undefined;
|
|
36
|
+
} | undefined) => import("supertest").Test;
|
|
26
37
|
clearCache: () => import("supertest").Test;
|
|
27
38
|
bundleInfo: () => import("supertest").Test;
|
|
28
39
|
};
|
|
@@ -30,7 +41,7 @@ export declare const runRealApp: (tramvaiConfigRoot: string, appName: string, op
|
|
|
30
41
|
close: (() => Promise<void>) & (() => Promise<void>);
|
|
31
42
|
invalidate: () => Promise<void>;
|
|
32
43
|
getBuildStats: import("@tramvai/cli/lib/typings/build/Builder").GetBuildStats;
|
|
33
|
-
staticServer?: import("http").Server | undefined;
|
|
34
|
-
server?: import("http").Server | undefined;
|
|
44
|
+
staticServer?: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | undefined;
|
|
45
|
+
server?: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | undefined;
|
|
35
46
|
builder: import("@tramvai/cli/lib/typings/build/Builder").Builder<any>;
|
|
36
47
|
}>;
|
package/lib/index.es.js
CHANGED
|
@@ -2,7 +2,6 @@ import { Writable } from 'stream';
|
|
|
2
2
|
import { start } from '@tramvai/cli';
|
|
3
3
|
import waitOn from 'wait-on';
|
|
4
4
|
import { requestFactory, renderFactory } from '@tramvai/test-helpers';
|
|
5
|
-
import supertest from 'supertest';
|
|
6
5
|
|
|
7
6
|
const getServerUrl = ({ server }) => {
|
|
8
7
|
const { port } = server === null || server === void 0 ? void 0 : server.address();
|
|
@@ -18,16 +17,16 @@ const getUtilityServerUrl = (env, { server }) => {
|
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
const wrapPapi = ({ serverUrl, appName }) => {
|
|
21
|
-
const publicPapi =
|
|
22
|
-
const privatePapi =
|
|
20
|
+
const publicPapi = requestFactory(`${serverUrl}/${appName}/papi/`);
|
|
21
|
+
const privatePapi = requestFactory(`${serverUrl}/${appName}/private/papi/`);
|
|
23
22
|
return {
|
|
24
23
|
publicPapi,
|
|
25
24
|
privatePapi,
|
|
26
25
|
clearCache: () => {
|
|
27
|
-
return privatePapi
|
|
26
|
+
return privatePapi(`clear-cache`, { method: 'post' }).expect(404).expect('X-Status', 'done');
|
|
28
27
|
},
|
|
29
28
|
bundleInfo: () => {
|
|
30
|
-
return publicPapi
|
|
29
|
+
return publicPapi('bundleInfo').expect(200);
|
|
31
30
|
},
|
|
32
31
|
};
|
|
33
32
|
};
|
|
@@ -36,20 +35,24 @@ const MOCKER_API_PATH = 'mocker-api';
|
|
|
36
35
|
const wrapMocker = ({ papi }) => {
|
|
37
36
|
return {
|
|
38
37
|
addMocks(api, mocks) {
|
|
39
|
-
return papi
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
return papi
|
|
39
|
+
.publicPapi(`${MOCKER_API_PATH}/mocks`, {
|
|
40
|
+
method: 'post',
|
|
41
|
+
body: {
|
|
42
|
+
api,
|
|
43
|
+
mocks,
|
|
44
|
+
},
|
|
44
45
|
})
|
|
45
46
|
.expect(200);
|
|
46
47
|
},
|
|
47
48
|
removeMocks(api, mocks) {
|
|
48
|
-
return papi
|
|
49
|
-
.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
return papi
|
|
50
|
+
.publicPapi(`${MOCKER_API_PATH}/mocks`, {
|
|
51
|
+
method: 'delete',
|
|
52
|
+
body: {
|
|
53
|
+
api,
|
|
54
|
+
mocks,
|
|
55
|
+
},
|
|
53
56
|
})
|
|
54
57
|
.expect(200);
|
|
55
58
|
},
|
package/lib/index.js
CHANGED
|
@@ -6,12 +6,10 @@ var stream = require('stream');
|
|
|
6
6
|
var cli = require('@tramvai/cli');
|
|
7
7
|
var waitOn = require('wait-on');
|
|
8
8
|
var testHelpers = require('@tramvai/test-helpers');
|
|
9
|
-
var supertest = require('supertest');
|
|
10
9
|
|
|
11
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
11
|
|
|
13
12
|
var waitOn__default = /*#__PURE__*/_interopDefaultLegacy(waitOn);
|
|
14
|
-
var supertest__default = /*#__PURE__*/_interopDefaultLegacy(supertest);
|
|
15
13
|
|
|
16
14
|
const getServerUrl = ({ server }) => {
|
|
17
15
|
const { port } = server === null || server === void 0 ? void 0 : server.address();
|
|
@@ -27,16 +25,16 @@ const getUtilityServerUrl = (env, { server }) => {
|
|
|
27
25
|
};
|
|
28
26
|
|
|
29
27
|
const wrapPapi = ({ serverUrl, appName }) => {
|
|
30
|
-
const publicPapi =
|
|
31
|
-
const privatePapi =
|
|
28
|
+
const publicPapi = testHelpers.requestFactory(`${serverUrl}/${appName}/papi/`);
|
|
29
|
+
const privatePapi = testHelpers.requestFactory(`${serverUrl}/${appName}/private/papi/`);
|
|
32
30
|
return {
|
|
33
31
|
publicPapi,
|
|
34
32
|
privatePapi,
|
|
35
33
|
clearCache: () => {
|
|
36
|
-
return privatePapi
|
|
34
|
+
return privatePapi(`clear-cache`, { method: 'post' }).expect(404).expect('X-Status', 'done');
|
|
37
35
|
},
|
|
38
36
|
bundleInfo: () => {
|
|
39
|
-
return publicPapi
|
|
37
|
+
return publicPapi('bundleInfo').expect(200);
|
|
40
38
|
},
|
|
41
39
|
};
|
|
42
40
|
};
|
|
@@ -45,20 +43,24 @@ const MOCKER_API_PATH = 'mocker-api';
|
|
|
45
43
|
const wrapMocker = ({ papi }) => {
|
|
46
44
|
return {
|
|
47
45
|
addMocks(api, mocks) {
|
|
48
|
-
return papi
|
|
49
|
-
.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
return papi
|
|
47
|
+
.publicPapi(`${MOCKER_API_PATH}/mocks`, {
|
|
48
|
+
method: 'post',
|
|
49
|
+
body: {
|
|
50
|
+
api,
|
|
51
|
+
mocks,
|
|
52
|
+
},
|
|
53
53
|
})
|
|
54
54
|
.expect(200);
|
|
55
55
|
},
|
|
56
56
|
removeMocks(api, mocks) {
|
|
57
|
-
return papi
|
|
58
|
-
.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
return papi
|
|
58
|
+
.publicPapi(`${MOCKER_API_PATH}/mocks`, {
|
|
59
|
+
method: 'delete',
|
|
60
|
+
body: {
|
|
61
|
+
api,
|
|
62
|
+
mocks,
|
|
63
|
+
},
|
|
62
64
|
})
|
|
63
65
|
.expect(200);
|
|
64
66
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/test-integration",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@types/wait-on": "^5.2.0"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tinkoff/mocker": "2.0
|
|
25
|
-
"@tramvai/test-helpers": "2.
|
|
24
|
+
"@tinkoff/mocker": "2.1.0",
|
|
25
|
+
"@tramvai/test-helpers": "2.24.3",
|
|
26
26
|
"@types/supertest": "^2.0.11",
|
|
27
27
|
"supertest": "^6.1.3",
|
|
28
28
|
"utility-types": "^3.10.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@tinkoff/utils": "^2.1.2",
|
|
33
|
-
"@tramvai/cli": "2.
|
|
33
|
+
"@tramvai/cli": "2.24.3",
|
|
34
34
|
"tslib": "^2.0.3"
|
|
35
35
|
},
|
|
36
36
|
"license": "Apache-2.0",
|