@tramvai/test-integration 7.16.0 → 7.17.1
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/startCli.d.ts +12 -0
- package/lib/app/startCli.es.js +57 -2
- package/lib/app/startCli.js +56 -0
- package/lib/index.es.js +1 -1
- package/lib/index.js +1 -0
- package/package.json +3 -3
package/lib/app/startCli.d.ts
CHANGED
|
@@ -8,6 +8,17 @@ export interface StartCliOptions extends Omit<StartOptions, 'config' | 'target'>
|
|
|
8
8
|
enableRebuild?: boolean;
|
|
9
9
|
logger?: Pick<typeof console, 'log' | 'error'>;
|
|
10
10
|
}
|
|
11
|
+
export declare const startChildApp: (targetOrConfig: StartOptions['target'] | StartOptions['config'], { enableRebuild, env, logger, ...cliOptions }?: StartCliOptions) => Promise<{
|
|
12
|
+
staticUrl: string;
|
|
13
|
+
stdout: Writable;
|
|
14
|
+
stderr: Writable;
|
|
15
|
+
close: (() => Promise<void>) & (() => Promise<void>);
|
|
16
|
+
invalidate: () => Promise<void>;
|
|
17
|
+
getBuildStats: import("@tramvai/cli/lib/typings/build/Builder").GetBuildStats;
|
|
18
|
+
staticServer?: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | undefined;
|
|
19
|
+
server?: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | undefined;
|
|
20
|
+
builder: import("@tramvai/cli/lib/typings/build/Builder").Builder<any>;
|
|
21
|
+
}>;
|
|
11
22
|
export declare const startCli: (targetOrConfig: StartOptions['target'] | StartOptions['config'], { enableRebuild, env, logger, ...cliOptions }?: StartCliOptions) => Promise<{
|
|
12
23
|
serverUrl: string;
|
|
13
24
|
staticUrl: string;
|
|
@@ -61,4 +72,5 @@ export declare const startCli: (targetOrConfig: StartOptions['target'] | StartOp
|
|
|
61
72
|
builder: import("@tramvai/cli/lib/typings/build/Builder").Builder<any>;
|
|
62
73
|
}>;
|
|
63
74
|
export type StartCliResult = PromiseType<ReturnType<typeof startCli>>;
|
|
75
|
+
export type StartChildAppResult = PromiseType<ReturnType<typeof startChildApp>>;
|
|
64
76
|
//# sourceMappingURL=startCli.d.ts.map
|
package/lib/app/startCli.es.js
CHANGED
|
@@ -5,7 +5,7 @@ import envCi from 'env-ci';
|
|
|
5
5
|
import { start } from '@tramvai/cli';
|
|
6
6
|
import waitOn from 'wait-on';
|
|
7
7
|
import { requestFactory, renderFactory } from '@tramvai/test-helpers';
|
|
8
|
-
import {
|
|
8
|
+
import { getStaticUrl, getServerUrl, getServerDomain, getUtilityServerUrl } from './utils.es.js';
|
|
9
9
|
export { getServerDomain, getServerUrl, getStaticUrl, getUtilityServerUrl } from './utils.es.js';
|
|
10
10
|
import { wrapPapi } from './papi.es.js';
|
|
11
11
|
import { wrapMocker } from './mocker.es.js';
|
|
@@ -14,6 +14,61 @@ if (typeof setDefaultResultOrder === 'function') {
|
|
|
14
14
|
setDefaultResultOrder('ipv4first');
|
|
15
15
|
}
|
|
16
16
|
const ciInfo = envCi();
|
|
17
|
+
const startChildApp = async (targetOrConfig, { enableRebuild = false, env, logger = console, ...cliOptions } = {}) => {
|
|
18
|
+
const stdout = new Writable({
|
|
19
|
+
write(chunk, _encoding, callback) {
|
|
20
|
+
logger.log(`[@tramvai/cli child app] log:`, chunk.toString());
|
|
21
|
+
callback();
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const stderr = new Writable({
|
|
25
|
+
write(chunk, _encoding, callback) {
|
|
26
|
+
logger.error(`[@tramvai/cli child app] error:`, chunk.toString());
|
|
27
|
+
callback();
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const cliResult = await start({
|
|
31
|
+
stdout,
|
|
32
|
+
stderr,
|
|
33
|
+
noClientRebuild: !enableRebuild,
|
|
34
|
+
noServerRebuild: !enableRebuild,
|
|
35
|
+
// build cache made tests unstable in CI, because of cache writing process are async,
|
|
36
|
+
// and there is no way to wait this process (`idleTimeoutForInitialStore: 0` helps sometimes, but no guarantees)
|
|
37
|
+
fileCache: !ciInfo.isCi,
|
|
38
|
+
// faster builds with debug flag, sm still will be disabled by default
|
|
39
|
+
sourceMap: cliOptions.sourceMap ?? false,
|
|
40
|
+
...(typeof targetOrConfig === 'string'
|
|
41
|
+
? { target: targetOrConfig }
|
|
42
|
+
: {
|
|
43
|
+
config: mergeDeep({
|
|
44
|
+
// disable hot-refresh that may break checks for full page load because of never-ending request
|
|
45
|
+
hotRefresh: { enabled: false },
|
|
46
|
+
// faster builds
|
|
47
|
+
sourceMap: false,
|
|
48
|
+
// faster builds
|
|
49
|
+
experiments: {
|
|
50
|
+
transpilation: {
|
|
51
|
+
loader: 'swc',
|
|
52
|
+
include: [
|
|
53
|
+
'@tinkoff/request',
|
|
54
|
+
'@tramvai/module-dev-tools',
|
|
55
|
+
'@tramvai-tinkoff/module-push-web',
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
}, targetOrConfig),
|
|
60
|
+
}),
|
|
61
|
+
env,
|
|
62
|
+
...cliOptions,
|
|
63
|
+
});
|
|
64
|
+
const staticUrl = getStaticUrl(cliResult);
|
|
65
|
+
return {
|
|
66
|
+
...cliResult,
|
|
67
|
+
staticUrl,
|
|
68
|
+
stdout,
|
|
69
|
+
stderr,
|
|
70
|
+
};
|
|
71
|
+
};
|
|
17
72
|
const startCli = async (targetOrConfig, { enableRebuild = false, env, logger = console, ...cliOptions } = {}) => {
|
|
18
73
|
const stdout = new Writable({
|
|
19
74
|
write(chunk, encoding, callback) {
|
|
@@ -117,4 +172,4 @@ const startCli = async (targetOrConfig, { enableRebuild = false, env, logger = c
|
|
|
117
172
|
};
|
|
118
173
|
};
|
|
119
174
|
|
|
120
|
-
export { startCli };
|
|
175
|
+
export { startChildApp, startCli };
|
package/lib/app/startCli.js
CHANGED
|
@@ -23,6 +23,61 @@ if (typeof dns.setDefaultResultOrder === 'function') {
|
|
|
23
23
|
dns.setDefaultResultOrder('ipv4first');
|
|
24
24
|
}
|
|
25
25
|
const ciInfo = envCi__default["default"]();
|
|
26
|
+
const startChildApp = async (targetOrConfig, { enableRebuild = false, env, logger = console, ...cliOptions } = {}) => {
|
|
27
|
+
const stdout = new stream.Writable({
|
|
28
|
+
write(chunk, _encoding, callback) {
|
|
29
|
+
logger.log(`[@tramvai/cli child app] log:`, chunk.toString());
|
|
30
|
+
callback();
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const stderr = new stream.Writable({
|
|
34
|
+
write(chunk, _encoding, callback) {
|
|
35
|
+
logger.error(`[@tramvai/cli child app] error:`, chunk.toString());
|
|
36
|
+
callback();
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
const cliResult = await cli.start({
|
|
40
|
+
stdout,
|
|
41
|
+
stderr,
|
|
42
|
+
noClientRebuild: !enableRebuild,
|
|
43
|
+
noServerRebuild: !enableRebuild,
|
|
44
|
+
// build cache made tests unstable in CI, because of cache writing process are async,
|
|
45
|
+
// and there is no way to wait this process (`idleTimeoutForInitialStore: 0` helps sometimes, but no guarantees)
|
|
46
|
+
fileCache: !ciInfo.isCi,
|
|
47
|
+
// faster builds with debug flag, sm still will be disabled by default
|
|
48
|
+
sourceMap: cliOptions.sourceMap ?? false,
|
|
49
|
+
...(typeof targetOrConfig === 'string'
|
|
50
|
+
? { target: targetOrConfig }
|
|
51
|
+
: {
|
|
52
|
+
config: mergeDeep__default["default"]({
|
|
53
|
+
// disable hot-refresh that may break checks for full page load because of never-ending request
|
|
54
|
+
hotRefresh: { enabled: false },
|
|
55
|
+
// faster builds
|
|
56
|
+
sourceMap: false,
|
|
57
|
+
// faster builds
|
|
58
|
+
experiments: {
|
|
59
|
+
transpilation: {
|
|
60
|
+
loader: 'swc',
|
|
61
|
+
include: [
|
|
62
|
+
'@tinkoff/request',
|
|
63
|
+
'@tramvai/module-dev-tools',
|
|
64
|
+
'@tramvai-tinkoff/module-push-web',
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
}, targetOrConfig),
|
|
69
|
+
}),
|
|
70
|
+
env,
|
|
71
|
+
...cliOptions,
|
|
72
|
+
});
|
|
73
|
+
const staticUrl = utils.getStaticUrl(cliResult);
|
|
74
|
+
return {
|
|
75
|
+
...cliResult,
|
|
76
|
+
staticUrl,
|
|
77
|
+
stdout,
|
|
78
|
+
stderr,
|
|
79
|
+
};
|
|
80
|
+
};
|
|
26
81
|
const startCli = async (targetOrConfig, { enableRebuild = false, env, logger = console, ...cliOptions } = {}) => {
|
|
27
82
|
const stdout = new stream.Writable({
|
|
28
83
|
write(chunk, encoding, callback) {
|
|
@@ -130,4 +185,5 @@ exports.getServerDomain = utils.getServerDomain;
|
|
|
130
185
|
exports.getServerUrl = utils.getServerUrl;
|
|
131
186
|
exports.getStaticUrl = utils.getStaticUrl;
|
|
132
187
|
exports.getUtilityServerUrl = utils.getUtilityServerUrl;
|
|
188
|
+
exports.startChildApp = startChildApp;
|
|
133
189
|
exports.startCli = startCli;
|
package/lib/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { startCli } from './app/startCli.es.js';
|
|
1
|
+
export { startChildApp, startCli } from './app/startCli.es.js';
|
|
2
2
|
export { buildCli } from './app/buildCli.es.js';
|
|
3
3
|
export { sleep } from './helpers/sleep.es.js';
|
|
4
4
|
export { getServerDomain, getServerUrl, getStaticUrl, getUtilityServerUrl } from './app/utils.es.js';
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/test-integration",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.17.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@tinkoff/mocker": "7.0.1",
|
|
24
|
-
"@tramvai/test-helpers": "7.
|
|
24
|
+
"@tramvai/test-helpers": "7.17.1",
|
|
25
25
|
"env-ci": "^5.0.2",
|
|
26
26
|
"utility-types": "^3.10.0",
|
|
27
27
|
"wait-on": "^5.3.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@tinkoff/utils": "^2.1.2",
|
|
31
|
-
"@tramvai/cli": "7.
|
|
31
|
+
"@tramvai/cli": "7.17.1",
|
|
32
32
|
"tslib": "^2.4.0"
|
|
33
33
|
},
|
|
34
34
|
"license": "Apache-2.0",
|